JavaScript JavaScript Arrays Loop Through Arrays Array Methods

Clare Yeadon
Clare Yeadon
5,422 Points

Use the method that returns the position of Saturn in the planets array

What am I doing wrong I get an error on my script and the error asks if I am joining but the questions ask for position,

script.js
const planets = ['Earth','Mars','Saturn','Mercury','Jupiter','Venus','Uranus','Neptune'];

console.log(planets.indexOf(`Saturn`));

1 Answer

Pete Webb
Pete Webb
8,517 Points

Hi Clare,

Absolutely nothing wrong with your answer to the challenge at all.

Easy to miss and not all challenges require it, there's a note at the bottom of some of the challenges saying you should keep the answer to previous tasks and build on top of them even if they don't solve the task specifically, as is the case here. "Important: In each task of this code challenge, the code you write should be added to the code from the previous task."

Clare Yeadon
Clare Yeadon
5,422 Points

Thank you that did the trick. I will keep my eye peeled for the "Important" note for future. Cheers!