I'm trying to program a button that randomly picks a color from the color array and chooses between these four values, and the color will be given to a new element.
They're classes that are defined in css. It's not working properly though as I don't see the issue with what I'm doing.
<script>
var colorArray = [ '.st1', '.st2', '.st3', '.st4'];
var randomColor = Math.floor(Math.random()*colorArray.length);
</script>
<label>
Class: <input type="text" id="new-class" value="randomColor">
</label>
<button type="button" onclick="addObject()">
Make Ball
</button>
Can anyone see to what I'm doing wrong?