Skip to content

Commit

Permalink
Solution
Browse files Browse the repository at this point in the history
  • Loading branch information
ydratsevska committed Aug 4, 2023
1 parent 94a32ce commit c5e5930
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/arrayMethodJoin.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@
*/
function applyCustomJoin() {
[].__proto__.join2 = function(separator = ',') {
let JOINED_ARRAY = '';
let joinedArray = '';

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

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

return JOINED_ARRAY;
return joinedArray;
};
}

Expand Down

0 comments on commit c5e5930

Please sign in to comment.