Skip to content

Finished Lesson_07 HW - Xavier Cruz #264

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

Closed

Conversation

XavierCruz5106
Copy link
Contributor

No description provided.

Copy link
Contributor

@anthonydmays anthonydmays left a comment

Choose a reason for hiding this comment

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

LGTM

return "F";
console.log(gpa);
switch (
true // better way to do this. want to use the equivilent of a Java Map (XavierCruz5106)
Copy link
Contributor

Choose a reason for hiding this comment

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

Interesting solution, though I wouldn't argue this is better than just using if statements (need a couple more lines of code for this construction). Nice though.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree it was the first solution that came to my head. the second was to use something like a java esque map of some sort and do a lookup instead of a comparison but im not sure how maps work in typescript so ive stray away from that approach

@@ -57,7 +98,11 @@ export function computeFactorial(n: number): number {
* @return The sum of all the values.
*/
export function addNumbers(values: number[]): number {
return 0;
let sum = 0;
values.forEach((value) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Would be better to use values.reduce. Know how to use it, comes in handy especially for interview prep but also IRL.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks ill look into .reduce!!

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