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

finally finished lab #225

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

kaycodeandsing
Copy link

No description provided.

result -= Number(newArg[i])
}
return result
} if (process.argv[2] !== "plus" || process.argv[2] !== "minus") {

Choose a reason for hiding this comment

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

modulo is hardcoded here. What if I use the operator division?

If i run node run.js 1 2 3, I get Invalid operation: modulo. How can you update this conditional to make sure you get the correct error message?

} if (process.argv[2] === "plus") {
let newArg = process.argv.slice(3);
let sum = 0;
sum = newArg.reduce((accumulator, value) => {

Choose a reason for hiding this comment

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

you can declare sum here instead of line 27 so : let sum = newArg.reduce(...)

} if( process.argv[2] === 'minus'){
let newArg = process.argv.slice(3);
let result = newArg[0]
for(let i = 1; i < newArg.length; i++){

Choose a reason for hiding this comment

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

with reduce and this loop, you have two accumulators, how can you refactor your code to not be repetitive.

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