Open
Conversation
problems/countNumbers.js
Outdated
|
|
||
| function countNumbers(arr) { | ||
| let count = {} | ||
| for (let i = 0; i < arr.length; i++) { |
Author
There was a problem hiding this comment.
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.
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.
No need for Math.floor here. A string will always be an integer length and never a decimal
| function removeNumbersAtOddIndices() { | ||
| function removeNumbersAtOddIndices(arr) { | ||
| let output = []; | ||
| for (i = 0; i < arr.length; i += 2) { |
There was a problem hiding this comment.
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.
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.
try using a for of loop when going through strings and not needing the index.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.