Aim of the puzzle: Use the
indexOf() array method to get the position of an element in an array.
Walk through of solution:
let fruit = ['apples', 'oranges']; console.log(fruit.indexOf('apples'));
This will print out
'apples' is the 1st item in the array.
In this puzzle, we will use
.indexOf() to find the position of
'YOU' in the
To complete the puzzle, remove the
let rank = 0, and replace it with
Sample code solution:
let highScores = [ 'JVN', 'CES', 'YOU', 'AMT', 'GBH' ]; let rank = highScores.indexOf('YOU'); console.log('You are number: ' + rank);