diff --git a/src/arrayMethodJoin.js b/src/arrayMethodJoin.js index 3a62201c..5b3d6d8b 100644 --- a/src/arrayMethodJoin.js +++ b/src/arrayMethodJoin.js @@ -4,8 +4,20 @@ * Implement method join */ function applyCustomJoin() { - [].__proto__.join2 = function(separator) { - // write code here + [].__proto__.join2 = function(separator = ',') { + let newString = ''; + + for (let i = 0; i <= this.length - 1; i++) { + if (this[i] !== undefined && this[i] !== null) { + newString += this[i]; + } + + if (i !== this.length - 1) { + newString += separator; + } + }; + + return newString; }; }