Ok, so I am new to Javascript. I have created an object with 3 separated arrays.
const messages = {
message:[
["joke1","joke2","joke3"],
["tease1","tease2","tease3"],
["boost1","boost2","boost3"]
};
now I need to take a random message every time the user logs in. so for example:
messages.message[0][2] or messages.message[2][0]
i cant get the second part of this code to work.
The first part was easy.
i was able to get the first random number from the array. that is put into the variable chooseArray1
here is where I am struggling.
const secondIndex = messages.message[chooseArray1[Math.floor(Math.random() * messages.message[chooseArray1])];
now Im getting an error here at the second [ in front of Math I cant seem to figure out how to get the random number of an array with an index.
I hope this makes sense. Apparently I have the coding skill of a rock.
Aucun commentaire:
Enregistrer un commentaire