-
Notifications
You must be signed in to change notification settings - Fork 168
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
Andres Ballares #172
base: master
Are you sure you want to change the base?
Andres Ballares #172
Conversation
newArray.push(array[i] + "!"); | ||
} | ||
return newArray; | ||
} |
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.
This looks good!
problems/arraysWithLoops.js
Outdated
|
||
/** | ||
* Takes in array and returns the smallest number in the array | ||
* @param {number[]} nums | ||
* @returns {number} smallest value | ||
*/ | ||
|
||
function findSmallest() {} | ||
function findSmallest(nums) { | ||
let i = 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.
We don't need this i here b/c we're declaring an i with our for loop.
function findSecondLargest(nums) { | ||
|
||
let largest = Infinity; | ||
let secondLargest = Infinity; |
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 we start at Infinity and are looking for the largest number, Infinity will always win. What's the smallest number in the world that we can start with?
i++; | ||
} else { | ||
arr.push(i + " is odd"); | ||
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.
we can move i++ outside / after the if else b/c it should increment regardless.
newArray.push(sum); | ||
} | ||
return newArray; | ||
}; |
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.
Nice job on these!
No description provided.