-
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
Miguel Garcia #175
base: master
Are you sure you want to change the base?
Miguel Garcia #175
Conversation
function shoutForLoop() {} | ||
function shoutForLoop(array) { | ||
let array2 = [] | ||
for (let i = 0; i < array.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 forget the brackets
for (let i = 0; i < nums.length; i++) { | ||
if (numSmall[i] < nums) | ||
return numSmall | ||
}} |
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.
Lets make sure we are using the curly brackets where appropriate. Rewrite your if statement to do something with the current smallest number
function findSecondSmallest(nums) { | ||
let secondSmallest = nums[0] | ||
for(let i = 0; i <= nums.length -1; i++) | ||
if (nums[i] <= secondSmallest) secondSmallest = nums [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.
you will need to add an extra condition to make sure that you are keep track of the second smallest number
function findSecondLargest(nums) { | ||
let secondLargest = nums [0] | ||
for (let i = 0; i <= nums.length - 1; i++) | ||
if (nums[i] >= secondLargest) secondLargest = nums [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.
Same goes here. Make sure you are keep track of the first largest AND the second largest.
function removeDups(nums) { | ||
let Dups = []; | ||
for (let i = 0; i < nums.length; i++) { | ||
if (! Dups.includes(nums[i])) { | ||
Dups.push(nums[i])} | ||
} return Dups | ||
} |
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 ! Don't forget to properly format your code so that it's easier to read and debug
if (num % 3 === 0) { | ||
arr.push("Fizz") | ||
} | ||
else if (num % 5 === 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.
The number 15 will pass this else if statement but it shouldn't because it is also divisible by 3
No description provided.