Skip to content

Commit

Permalink
Solution
Browse files Browse the repository at this point in the history
  • Loading branch information
ydratsevska committed Aug 7, 2023
1 parent c5e5930 commit 7f1d80a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/arrayMethodJoin.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ function applyCustomJoin() {
[].__proto__.join2 = function(separator = ',') {
let joinedArray = '';

for (let i = 0; i < this.length; i++) {
if (this[i] != null && this[i] !== undefined) {
joinedArray += this[i];
for (const word of this) {
if (word != null && word !== undefined) {
joinedArray += word;
}

if (i !== this.length - 1) {
if (this.indexOf(word) !== this.length - 1) {
joinedArray += separator;
}
}
Expand Down

0 comments on commit 7f1d80a

Please sign in to comment.