-
Notifications
You must be signed in to change notification settings - Fork 12
JavaScript functions #11
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
base: master
Are you sure you want to change the base?
Conversation
Krivorotova Tatyana/largest.js
Outdated
| function largest(arr) | ||
| { | ||
| let numbers = []; | ||
| for(let i = 0; i < arguments.length; ++i) |
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.
what's the propose of transforming arguments to real array? you didn't use any of array methods.
Krivorotova Tatyana/largest.js
Outdated
| /* largest */ | ||
| function largest(arr) | ||
| { | ||
| let numbers = []; |
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 is the part of ES6/ES2015 - it's forbidden for this hw
Krivorotova Tatyana/reverseString.js
Outdated
| @@ -0,0 +1,10 @@ | |||
| /* reverseString */ | |||
| function reverseString(str){ | |||
| str = str.split(' '); | |||
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.
try to not modify arguments of function - in some cases it could lead to unexpected side effects in your apps
Krivorotova Tatyana/smallest.js
Outdated
| { | ||
| let numbers = []; | ||
| for(let i = 0; i < arguments.length; ++i) | ||
| numbers[i] = arguments[i]; |
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.
the same as for largest function
| function splitAndMerge(str, sp){ | ||
| let wrds = str.split(' '); | ||
| const chars = []; | ||
| for(let i = 0; i < wrds.length; ++i) |
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.
don't use for, if without brackets - it decreases readability of your code
Krivorotova Tatyana/splitAndMerge.js
Outdated
| /* splitAndMerge */ | ||
| function splitAndMerge(str, sp){ | ||
| let wrds = str.split(' '); | ||
| const chars = []; |
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.
maybe something like wordsWithSP or modifiedWords? - chars is confusing name
| /* sum */ | ||
| function sum() | ||
| { | ||
| return arguments.length === 0? 0 : arguments[0] + sum.apply(0, Array.prototype.slice.call(arguments, 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.
Actually, I'm ok with that solution, but maybe better to use here reduce instead of recursion?
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.
oh, ignore this comment - I didn't see that recursion is the requirement
No description provided.