FAQ: Code Challenges: JavaScript Fundamentals - calculateWeight()

It doesn’t work? Looping over the array, the first element will always be Mercury, so this condition is always true:

if(planets[i] === "Mercury")

so you will always get the weight on mercury

You are so right. When looping is going to check each value inside the array and my logic sets it to the first element, regardless. Thanks !!. I wanted to try something different,

1 Like