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 trialDaniela Garcia
5,071 PointsBummer: Are you using the method that joins array elements and returns a new string?
What's my error here?
const planets = ['Earth','Mars','Saturn','Mecury','Jupiter','Venus','Uranus','Neptune'];
console.log(planets.indexOf('Saturn'));
2 Answers
Peter Vann
36,427 PointsHi Daniela!
This passes both tasks:
const planets = ['Earth','Mars','Saturn','Mecury','Jupiter','Venus','Uranus','Neptune'];
// Task 1
const planetStr = planets.join(", ");
console.log(planetStr);
// Task 2
const pos = planets.indexOf('Saturn');
console.log(pos);
This would also work (not using variables):
const planets = ['Earth','Mars','Saturn','Mecury','Jupiter','Venus','Uranus','Neptune'];
// Task 1
console.log( planets.join(", ") );
// Task 2
console.log( planets.indexOf('Saturn') );
I hope that helps.
Stay safe and happy coding!
Peter Vann
36,427 PointsCan I see your whole actual block of code?
Some typos are elusive!?!
Clare Yeadon
5,553 Pointsconst planets = ['Earth','Mars','Saturn','Mercury','Jupiter','Venus','Uranus','Neptune'];
console.log(planets.indexOf(Saturn
));
Clare Yeadon
5,553 PointsClare Yeadon
5,553 PointsGood morning, My answer for task 2 was the same as your but I copied and pasted your since maybe I was missing a space or something and I am still getting the same "Bummer wrong answer". Any thoughts?