Skip to content

Commit

Permalink
fix task
Browse files Browse the repository at this point in the history
  • Loading branch information
Vitalii Serhiichuk committed Aug 4, 2023
1 parent 8f723ed commit 4485635
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/arrayMethodJoin.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,27 @@
*/
function applyCustomJoin() {
[].__proto__.join2 = function(separator = ',') {
let str = '';
let returnString = '';
let valueSeparatore = separator;

if (separator === null) {
valueSeparatore = 'null';
}

for (let i = 0; i < this.length; i++) {
const arrayValue = this[i] === undefined
const arrayElement = this[i] === undefined
|| this[i] === null
? ''
: this[i];

if (i < this.length - 1) {
str += arrayValue + valueSeparatore;
returnString += arrayElement + valueSeparatore;
} else {
str += arrayValue;
returnString += arrayElement;
}
}

return str;
return returnString;
};
}

Expand Down

0 comments on commit 4485635

Please sign in to comment.