I'm trying to output a random word into a specific html element. I'm almost there - but I think I'm messing up the part which prints the text...
Can anyone give me a tip as to where I'm going wrong ?
var txtGreeting = 10;
var randomCount = Math.round(Math.random() * (txtGreeting - 1)) + 1;
var greeting = new Array();
greeting[1] = "hello",
greeting[2] = "ciao",
greeting[3] = "welcome",
greeting[4] = "howdy",
greeting[5] = "greetings",
greeting[6] = "salut",
greeting[7] = "hallo",
greeting[8] = "hola",
greeting[9] = "Gday",
greeting[10] = "Hey",
document.getElementById("title").html = "greeting[randomCount]";
.innerHTML;) So close! There's also some minor issues with your syntax for instance those,s should be;s."greeting[randomCount]"bit wrapped in quotes, since that will be interpreted as a literal string of text.new Array!!! And the way you are using it is wrong: 1. It should benew Array()2: An array starts at 0, not 1.