From 4485635750af87c201e87424262b49cf34a453a8 Mon Sep 17 00:00:00 2001 From: Vitalii Serhiichuk Date: Fri, 4 Aug 2023 14:46:20 +0300 Subject: [PATCH] fix task --- src/arrayMethodJoin.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/arrayMethodJoin.js b/src/arrayMethodJoin.js index 5082d174..cd488788 100644 --- a/src/arrayMethodJoin.js +++ b/src/arrayMethodJoin.js @@ -5,7 +5,7 @@ */ function applyCustomJoin() { [].__proto__.join2 = function(separator = ',') { - let str = ''; + let returnString = ''; let valueSeparatore = separator; if (separator === null) { @@ -13,19 +13,19 @@ function applyCustomJoin() { } 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; }; }