Skip to content

Commit

Permalink
mySolution
Browse files Browse the repository at this point in the history
  • Loading branch information
AntonFof committed Sep 9, 2023
1 parent d04c9f0 commit a8b82b4
Showing 1 changed file with 18 additions and 1 deletion.
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 = '';
let separatorSign = separator;

if (separator === undefined) {
separatorSign = ',';
}

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

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

return result;
};
}

Expand Down

0 comments on commit a8b82b4

Please sign in to comment.