Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork120
Done all tasks#17
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 ourterms of service andprivacy 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?
Uh oh!
There was an error while loading.Please reload this page.
Conversation
Exercises/2-for-of.js Outdated
| // to calculate sumofall given arguments | ||
| // For example sum(1, 2, 3) shouldreturn6 | ||
| letsum=0; | ||
| for(constiofargs)sum+=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.
i is not a good naming for array element, it means index in array but here isi isn't an index
Exercises/4-do-while.js Outdated
| } | ||
| while(i<args.length); |
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.
Better put it in a single line:} while (i < args.length);
Exercises/4-do-while.js Outdated
| // For example sum(1, 2, 3) should return 6 | ||
| if(args.length<1)return0; | ||
| letsum=0; | ||
| leti=0; |
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.
Having counter and not using pop/shift is much better for performance 👍
Exercises/6-matrix.js Outdated
| for(leti=0;i<matrix.length;i++){ | ||
| for(letj=0;j<matrix[i].length;j++){ | ||
| //max = max < matrix[i][j] ? matrix[i][j] : max; | ||
| if(max<matrix[i][j])max=matrix[i][j]; |
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.
Expressionmatrix[i][j] repeated twice, and we have additionalmatrix[i] in line 6. See my solution to optimize code.
Exercises/6-matrix.js Outdated
| // Use nested for loop to find max value in 2d matrix | ||
| // For example max([[1, 2, 3], [4, 5, 6], [7, 8, 9]]) | ||
| // should return 9 | ||
| letmax=0; |
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.
You can name variable as a function but it will be better to use different name.
Exercises/7-ages.js Outdated
| // } | ||
| constages={}; | ||
| for(constelementinpersons){ | ||
| ages[element]=persons[element]['died']-persons[element]['born']; |
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.
| ages[element]=persons[element]['died']-persons[element]['born']; | |
| constperson=persons[element]; | |
| ages[element]=person.died-persons.born; |
Exercises/7-ages.js Outdated
| // gandhi: 79, | ||
| // hirohito: 88, | ||
| // } | ||
| constages={}; |
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.
Use different variable name
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.
👍
No description provided.