3
JS Assignment 9: Intro to Arrays
gustavoyepez (3)

Hello i need help in this exercise:

function exerciseThree(bandsArray){
// Exercise Three: In this function you will be given an array called 'bandsArray'.
// console log the third band in the array.
// Note: DO NOT create a new array in this challenge.
// Note: Remember that array indecies start at 0.
}

You are viewing a single comment. View All
Answered by mwilki7 (108) [earned 5 cycles]
View Answer
1
mwilki7 (108)

What have you got so far or do you need help on where to start?

1
mwilki7 (108)

@gustavoyepez
I assume they mean each element of an array is a "band"
What you have so far is the correct logic, you just need the correct array index.

They want the third element. To know for sure you have the third element, just count from the first:
(arrays start from 0)
0 - first
1 - second
2 - third

So you want to be using bandArray[2] instead of bandsArray[4] because "2" is the third element, "4" would be the fifth

1
gustavoyepez (3)

@mwilki7 well not much so far because i do not understand what does it mean by "console log the third band in the array."

so what i got is this:
console.log(bandsArray[4]);

2
gustavoyepez (3)

@mwilki7 Oh yea. It worked! thank you so much!