As said above. Here is an example of the kind of code I am trying to use:
http://codepen.io/anon/pen/LGLJXd
<button id='myButt' onclick='randGen()'>New Target</button>
<button id="myOtherButt" onclick='clear()'>Clear</button>
<p id='test'>Click me to randomly choose from the array!</p>
And then JS;
var myArray = ["Empire", "Rebels", "Scum", "Clones", "Trade Federation", "Sith", "Jedi"];
var rand = myArray[Math.floor(Math.random() * myArray.length)];
function randGen() {
document.getElementById('test').innerHTML = rand;
};
function clear() {
document.getElementById('test').innerHTML = 'No';
};
It works well once, but 'clear' or trying to use the First button more than once is not responsive. Could someone help me understand what I'm not doing right?
randonly once. So you get the same result every time. Move the line `var rand = (...) into the function.