10. Array Positions


#1

Hello! I'm having a problem with the excersize Array Positions.
my code looks like this:

var junkData = ["Eddie Murphy", 49, "peanuts", 31];
console.log=junkData[3];

and the console prints 31, but i get the feedback "Oops, try again. Alas, you should have printed 31, as that is the 4th element!"

after searching around the fora i also tried the following code:

var junkData = ["Eddie Murphy", 49, "peanuts", 31];
console.log(junkData[3])

but that gives the feedback "TypeError: console.log is not a function"


#2

Well name = value means that you assign a value to a variable so because of this statement:

console.log=junkData[3];

console.log is not longer the function that prints stuff to the console but the value 31 which is stored in junkData[3]. To fix this you need to refresh the page to reset the javaScript.


#3

Thank you very much, that worked!! I didn't know that this could mess with the code that much