+ 8

SoloLearn quiz??

Let arr = arr[1,2,3,4]; alert(arr[arr[1]); To find the index you count from zero... but the answer is 3, why???🤔🤔🤔🤔

30th Jun 2019, 4:50 PM
Kae🙌🏽☕️
Kae🙌🏽☕️ - avatar
4 Answers
+ 6
arr[1] is the second element of the array, so it will be 2. arr[2] will be this third element, so it will be 3
30th Jun 2019, 4:55 PM
Airree
Airree - avatar
+ 6
Airree exactly what i got, but when i ran the code through the console it gave me 3😳
30th Jun 2019, 6:37 PM
Kae🙌🏽☕️
Kae🙌🏽☕️ - avatar
+ 6
Airree the arr[arr[1]]. i wonder the first arr[], automatically takes 0 position as the starting position that does make sense and then when the next arr is nested marks the ending position - arr[arr[1]] ... doea not make sense ..... but thats alot for helping me work this out 😊😊
30th Jun 2019, 6:42 PM
Kae🙌🏽☕️
Kae🙌🏽☕️ - avatar
+ 3
Yeah, the result is 3
30th Jun 2019, 6:37 PM
Airree
Airree - avatar