Skip to content
Closed
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) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider using plus operator with assignment operator = if you want to add something to existing value.

See the [CODE STYLE] in checklist #3.

result += separator;
}
}

return result;
};
}

Expand Down