Skip to content

Commit

Permalink
Solution
Browse files Browse the repository at this point in the history
  • Loading branch information
Orpheus29 committed Aug 3, 2023
1 parent d04c9f0 commit 66e8f9c
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions src/arrayMethodJoin.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,22 @@
* Implement method join
*/
function applyCustomJoin() {
[].__proto__.join2 = function(separator) {
// write code here
[].__proto__.join2 = function(separator = ',') {
let stringFromJoinedArray = '';

for (let i = 0; i < this.length; i++) {
const itemContent
= this[i] === null || this[i] === undefined
? ''
: this[i];

stringFromJoinedArray
+= i === 0
? itemContent
: `${separator}` + itemContent;
}

return stringFromJoinedArray;
};
}

Expand Down

0 comments on commit 66e8f9c

Please sign in to comment.