-
Notifications
You must be signed in to change notification settings - Fork 39
Review #75
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?
Review #75
Conversation
problems/countNumbers.js
Outdated
|
|
||
| function countNumbers(arr) { | ||
| let count = {} | ||
| for (let i = 0; i < arr.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.
Try using forEach here
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.
Did it! seems like a longer code. Thank you
problems/isOdd.js
Outdated
| function isOdd() { | ||
|
|
||
| function isOdd(n) { | ||
| if (n % 2 === 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.
can just return the condition n % 2 === 1
problems/numberOfDigits.js
Outdated
|
|
||
| function numberOfDigits(n) { | ||
| let num = n | ||
| return Math.floor(num.toString().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.
No need for Math.floor here. A string will always be an integer length and never a decimal
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.
Noted. Thank you
| function removeNumbersAtOddIndices() { | ||
| function removeNumbersAtOddIndices(arr) { | ||
| let output = []; | ||
| for (i = 0; i < arr.length; i += 2) { |
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 using filter here. But I do love your i += 2
| let arr = str.split("") | ||
| let out = []; | ||
| for (let i = 0; i < arr.length; i++) { | ||
| if (arr[i] !== "o" && arr[i] !== "e" && arr[i] !== "u" && arr[i] !== "i" && arr[i] !== "A" && arr[i] !== "E" && arr[i] !== "I" && arr[i] !== "U" && arr[i] !== "O" && arr[i] !== "a") { |
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.
check out the includes method "aeiouAEIOU".includes(arr[i])
| function removeVowels(str) { | ||
| let arr = str.split("") | ||
| let out = []; | ||
| for (let i = 0; i < arr.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.
try using a for of loop when going through strings and not needing the index.
No description provided.