JavaScript JavaScript Arrays Loop Through Arrays Array Methods

Shanna vick-Morris
Shanna vick-Morris
5,947 Points

Javascript Arrays

Next, use the method that returns the position of 'Saturn' in the planets array. Log the return value to the console.

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

planets.indexOf('Saturn')
console.log(planets.indexOf(', ') );

2 Answers

const planets = ['Earth','Mars','Saturn','Mecury','Jupiter','Venus','Uranus','Neptune'];
console.log(planets.join(', '));
console.log(planets.indexOf('Saturn'));

Good luck :))

William Ray Noble
William Ray Noble
22,189 Points

Have you tried assigning planet.indexOf('Saturn') to a variable and then console logging the variable?

const Saturn = planets.indexOf('Saturn'); console.log(Saturn);

That works too.