Skip to content

Commit

Permalink
solution
Browse files Browse the repository at this point in the history
  • Loading branch information
Yaroslav220890 committed Jan 26, 2024
1 parent d04c9f0 commit cb3658c
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/arrayMethodJoin.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,22 @@
/**
* Implement method join
*/

function applyCustomJoin() {
[].__proto__.join2 = function(separator) {
// write code here
[].__proto__.join2 = function(separator = ',') {
let string = '';

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

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

return string;
};
}

Expand Down

0 comments on commit cb3658c

Please sign in to comment.