Ask coding questions

← Back to all posts
JS Assignment 9: Intro to Arrays
gustavoyepez (7)

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.
}

Answered by mwilki7 (519) [earned 5 cycles]
View Answer
Commentshotnewtop
mwilki7 (519)

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

gustavoyepez (7)

@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]);

mwilki7 (519)

@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

gustavoyepez (7)

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

nyiaevans (2)

I tried that answer and it did not work for me

JwalyaOza (3)

can anyone guide me towards solving this js assignment 9? i really need help in order to finish it as soon as possible