I've just started learning Javascript and need some help.
I wanted to build a random picker from an array which I accomplished
var movie = ["star wars", "lotr", "moonlight", "avengers"]
function newMovie() {
var randomNumber = Math.floor(Math.random() * (movie.length));
document.getElementById("display").innerHTML = "You should watch " + movie[randomNumber];
}
Now I want to add more options for such as books, games.. so I've created an object for it:
var chooseOption = {
watch: ["star wars", "lotr", "moonlight", "avengers"],
read: ["scott pilgrim", "harry potter", "eragon"],
play: ["starbound", "skyrim", "bioshock", "fallout"]
}
I'm a bit lost on how to proceed - I want it to first pick out one of the properties and then one of the values of the said property, all by random.
And then print it out in a "You should" + [property] + [value]
How would I do that? Is the object a way to go, or any better options?