Skip to content

Commit

Permalink
fix bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
deandre25 committed Aug 3, 2023
1 parent daf67ce commit 834f55e
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions src/arrayMethodJoin.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,19 @@ function applyCustomJoin() {
return '';
}

let res = '';
let joinedString = '';

if (this[0] === null) {
res += ``;
} else {
res += `${this[0]}`;
}
for (let i = 0; i < this.length; i++) {
if (this[i] !== null && this[i] !== undefined) {
joinedString += this[i];
}

for (let i = 1; i < this.length; i++) {
if (this[i] === null || this[i] === undefined) {
res += `${separator}`;
} else {
res += `${separator}${this[i]}`;
};
if (i !== this.length - 1) {
joinedString += separator;
}
}

return res;
return joinedString;
};
}

Expand Down

0 comments on commit 834f55e

Please sign in to comment.