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