Skip to content
Closed

Develop #2764

Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion src/arrayMethodJoin.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,24 @@
*/
function applyCustomJoin() {
[].__proto__.join2 = function(separator) {
// write code here
let result = '';

if (separator === undefined) {
// eslint-disable-next-line no-param-reassign
separator = ',';
}

for (let i = 0; i < this.length; i++) {
if (this[i] !== null && this[i] !== undefined) {
result += this[i];
}

if (i !== this.length - 1) {
result += separator;
}
}

return result;
};
}

Expand Down