Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript JavaScript Arrays Loop Through Arrays Array Methods

Clare Yeadon
Clare Yeadon
5,452 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,518 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,452 Points

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