-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
added solution task #2748
base: master
Are you sure you want to change the base?
added solution task #2748
Conversation
src/arrayMethodJoin.js
Outdated
let value = this[i]; | ||
|
||
if (value === undefined || value === null) { | ||
value = ''; | ||
} | ||
|
||
if (i === 0) { | ||
result += value; | ||
} else { | ||
result += readySeparator + value; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let value = this[i]; | |
if (value === undefined || value === null) { | |
value = ''; | |
} | |
if (i === 0) { | |
result += value; | |
} else { | |
result += readySeparator + value; | |
} | |
let value = this[i]; | |
if (value !== undefined && value !== null) { | |
result += value; | |
} | |
if (i !== this.length - 1) { | |
result += readySeparator; | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well done
src/arrayMethodJoin.js
Outdated
@@ -5,7 +5,22 @@ | |||
*/ | |||
function applyCustomJoin() { | |||
[].__proto__.join2 = function(separator) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[].__proto__.join2 = function(separator) { | |
[].__proto__.join2 = function(separator = ',') { |
@@ -5,7 +5,22 @@ | |||
*/ | |||
function applyCustomJoin() { | |||
[].__proto__.join2 = function(separator) { | |||
// write code here | |||
let result = ''; | |||
const readySeparator = separator !== undefined ? String(separator) : ','; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
default value looks more readable
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One more try
No description provided.