Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript JavaScript Arrays Loop Through Arrays Array Methods

Clare Yeadon
Clare Yeadon
5,553 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

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,553 Points

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