Skip to content

added solution task#2748

Open
shikoryak wants to merge 4 commits intomate-academy:masterfrom
shikoryak:develop
Open

added solution task#2748
shikoryak wants to merge 4 commits intomate-academy:masterfrom
shikoryak:develop

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

@shikoryak shikoryak requested a review from etojeDenys September 4, 2023 08:57
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 = ',') {

[].__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