Heterogeneous arrays need help


#1

i need the explanation for the * marked code line , why i hve to write it true ? is there anyway to write the total code in easiest way ?

var needForSpeed = new Object();
 * needForSpeed['mostWanted'] = true;
var myArray = [18,true,"Chi0gy", [needForSpeed]];
console.log(myArray);

#2

Maybe something like this would be easier?

var needforSpeed = {
something: whatever}

var myArray = [18, true, "Chiogy", needforSpeed];
console.log(myArray);

#3

its cannot work here.


#4

Well I just put that in the lesson and it passed fine. Don't see why it wouldn't work? Are you wanting something else in the code? Obviously in the code I gave you you have to fill in the something and whatever point but you should be able to figure that out


#5

i need the explanation of star(*) marked line . why i hve to write it ?


#6

Well first off you don't have to have it in your code for it to work. But if you really want an explanation I can try and find one. Sorry, I am not trying to be stubborn I just don't know why you want to use it because it is not necessary for producing a fine code. Usually * just means times in Javascript honestly unless you are using a function* or generator as far as I can tell.


#7

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.