There are currently no frequently asked questions associated with this exercise – that’s where you come in! You can contribute to this section by offering your own questions, answers, or clarifications on this exercise. Ask or answer a question by clicking reply () below.
If you’ve had an “aha” moment about the concepts, formatting, syntax, or anything else with this exercise, consider sharing those insights! Teaching others and answering their questions is one of the best ways to learn and stay sharp.
Join the Discussion. Help a fellow learner on their journey.
Ask or answer a question about this exercise by clicking reply () below!
Agree with a comment or answer? Like () to up-vote the contribution!
I used this code, which I’ve tested in the terminal and elsewhere, which does work:
const Calculate = {
sum(inputArray) {
const result = inputArray.reduce((a, b) => {
return a + b;
})
return result;
}
}
It seems the exercise wants us to specifically use a for…of loop instead of e.g. an array.reduce() method, but this isn’t specified anywhere, so that a little unhelpful when the code still works - surely the exercise’s pass condition should reflect the output of the tests we’re running?
I attempted to solve it using the reduce iterator, but I keep getting an error. I believe I’ve implemented it correctly so it might be a CodeAcademy issue.