Ask coding questions

← Back to all posts
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.
}

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

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

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

1
mwilki7 (130)

@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

2
gustavoyepez (3)

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

2
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

1
nyiaevans (0)

I tried that answer and it did not work for me