diff --git a/src/arrayMethodJoin.js b/src/arrayMethodJoin.js index 3a62201c..ba32a6ad 100644 --- a/src/arrayMethodJoin.js +++ b/src/arrayMethodJoin.js @@ -5,7 +5,24 @@ */ function applyCustomJoin() { [].__proto__.join2 = function(separator) { - // write code here + let result = ''; + + if (separator === undefined) { + // eslint-disable-next-line no-param-reassign + separator = ','; + } + + 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; }; }