Skip to content

solution#2741

Open
oleg-matvienko wants to merge 3 commits intomate-academy:masterfrom
oleg-matvienko:develop
Open

solution#2741
oleg-matvienko wants to merge 3 commits intomate-academy:masterfrom
oleg-matvienko:develop

Conversation

@oleg-matvienko
Copy link

No description provided.

Copy link

@roman-mirzoian roman-mirzoian left a comment

Choose a reason for hiding this comment

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

Good job, but there is quite a bit of work to be done.

Comment on lines 11 to 13
if (this[i] !== null && this[i] !== undefined) {
resultString += this[i];
}

Choose a reason for hiding this comment

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

We use this[i] three times, so we can put it in a variable.

[].__proto__.join2 = function(separator) {
// write code here
[].__proto__.join2 = function(separator = ',') {
let resultString = '';

Choose a reason for hiding this comment

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

The variable name is fine, but I would add a more precise name.

Suggested change
let resultString = '';
let joinedString = '';

Copy link

@roman-mirzoian roman-mirzoian left a comment

Choose a reason for hiding this comment

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

Almost done!

// write code here
[].__proto__.join2 = function(separator = ',') {
let joinedString = '';
let value = [];

Choose a reason for hiding this comment

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

It is not necessary to bring the definition of a variable that is used in the middle of the loop outside.
You should also think about better naming.

Copy link

@Moroz-Dmytro Moroz-Dmytro left a comment

Choose a reason for hiding this comment

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

👍

let joinedString = '';

for (let i = 0; i < this.length; i++) {
const valueOfArray = this[i];

Choose a reason for hiding this comment

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

But still not a good name

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