I'm trying to make an alert box pop up with one random sentence from an array of sentences inside it. This is my code:
var tasks = [
"This is the first task",
"And this is the second task",
"Third task..."
];
var randomTask = Math.floor((Math.random() * tasks.length) - 1);
alert(tasks[randomTask]);
If you run it, the only thing the pop says is "undefined". Why doesn't it work?
Thanks to anyone that answers! :-)