Skip to content
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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open

added solution task #2748

wants to merge 4 commits into from

Conversation

shikoryak
Copy link

No description provided.

Comment on lines 12 to 22
let value = this[i];

if (value === undefined || value === null) {
value = '';
}

if (i === 0) {
result += value;
} else {
result += readySeparator + value;
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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;
}

Copy link

@IvanFesenko IvanFesenko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well done

@@ -5,7 +5,22 @@
*/
function applyCustomJoin() {
[].__proto__.join2 = function(separator) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
[].__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) : ',';

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

Copy link

@IvanFesenko IvanFesenko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.

Copy link

@IvanFesenko IvanFesenko left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One more try

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants