-
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
feat: add task solution #2674
base: master
Are you sure you want to change the base?
feat: add task solution #2674
Conversation
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.
Great work🚀
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.
GJ 👍
Small comments to improve your code
src/arrayMethodJoin.js
Outdated
[].__proto__.join2 = function(separator) { | ||
// write code here | ||
[].__proto__.join2 = function(separator = ',') { | ||
const currentArray = this; |
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.
I guess we don't really need to create this variable
src/arrayMethodJoin.js
Outdated
if (!(currentArray instanceof Array)) { | ||
return ''; | ||
} |
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.
On line 10 you create this method as a method of Array
. So this method can be called only on array
src/arrayMethodJoin.js
Outdated
return ''; | ||
} | ||
|
||
const INDEX_OF_LAST_ELEMENT = currentArray.length - 1; |
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.
If you want to create variable for this, name it in camelCase
|
||
let concatedString = ''; | ||
|
||
for (let curIndex = 0; curIndex < this.length; curIndex++) { |
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.
I feel like curIndex is a redundant name, because everyone knows that 'i' is current index ;)
@@ -3,9 +3,28 @@ | |||
/** | |||
* Implement method join | |||
*/ | |||
|
|||
const isNotIgnoredEl = (el) => ![null, undefined].includes(el); |
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's check if element isIgnored, and then set value to opposite, in place where we call it, I guess that's gonna be more correct
No description provided.