Skip to content
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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Conversation

AndresBallares
Copy link

No description provided.

newArray.push(array[i] + "!");
}
return newArray;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good!


/**
* 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;
Copy link
Contributor

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;
Copy link
Contributor

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++;
Copy link
Contributor

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;
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice job on these!

@AndresBallares
Copy link
Author

AndresBallares commented Jan 25, 2021 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants