Skip to content

Conversation

@michaelgrilo
Copy link
Contributor

Here I'm trying to make it more explicit that a global variable is needed as a container for the sum. I didn't pick up on this and tried to fit everything into the for loop. I might be spelling things out too much with this commit, but I had to look at the solution before I could understand this problem.

I also tried to make the writing in this problem more concise.

Here I'm trying to make it more explicit that a global variable is needed as a container for the sum. I didn't pick up on this and tried to fit everything into the `for loop`. I might be spelling things out too much with this commit, but I had to look at the solution before I could understand this problem. 

I also tried to make the writing in this problem more concise.
@martinheidegger
Copy link
Contributor

LGTM @workshopper/owners ?

Think about how to loop through the number arguments so you can output only their sum. The first element of the `process.argv` array is always 'node', and the second element is always the path to your program.js file. You'll need to start at the 3rd element (index 2), adding each element to the total sum until you reach the end of the array.

Also be aware that all elements of `process.argv` are strings and you may need to *coerce* them into numbers. You can do this by prefixing the property with `+` or passing it to `Number()`. e.g. `+process.argv[2]` or `Number(process.argv[2])`.
Try to remember what kind of statement JavaScript uses to hold on to values. What scope such a container would need? Which value would it initially be assigned to?
Copy link
Member

Choose a reason for hiding this comment

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

This is more confusing IMO

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants