diff --git a/src/arrayMethodJoin.js b/src/arrayMethodJoin.js index 3a62201c..35557402 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 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; }; }