Reply
Thu 2 Apr, 2015 10:58 am
I want to know how to print the randomly selected text but I am unsure how. Here is the code.
<!DOCTYPE html>
<html>
<body>
<h1>JavaScript in Body</h1>
<button type="button" onclick="myFunction()">Click For New Adjective</button>
<p id="word">adjectives</p>
<script>
var description = [
"yayay",
"chicken",
"what",
"hey"
];
var size = description.length
var x = Math.floor(size*Math.random())
document.getElementById('word').src=description[x];
</script>
</body>
</html>