diff --git a/src/arrayMethodJoin.js b/src/arrayMethodJoin.js index 3a62201c..67b6d7d8 100644 --- a/src/arrayMethodJoin.js +++ b/src/arrayMethodJoin.js @@ -1,11 +1,19 @@ -'use strict'; - -/** - * Implement method join - */ +"use strict"; function applyCustomJoin() { - [].__proto__.join2 = function(separator) { - // write code here + [].__proto__.join2 = function (separator = ",") { + let str = ""; + + for (let i = 0; i <= this.length; i++) { + if (this[i] !== null && this[i] !== undefined) { + str += this[i]; + } + + if (i < this.length - 1) { + str += separator; + } + } + + return str; }; }