lundi 1 février 2016

Pick a random item from a list

I'm learning Javascript and i need some help. I have a list. I've tried to make a list, where you can, by the click of a button, get a random song from that list, but it doesn't seem to work. My list is down below, what am i doing wrong?

<!DOCKTYPE html>
<html>
<head>
</head>
<body>

<div>
  <button type="randomSong">Random Music</button>
  <input "randomSong" id="randomSong">
</div>

<script>

var song = Array("song1", "song2", "song3", "song4", "song5", "song6");

var randomSong = song[Math.floor(Math.random()*song.length)];

</script>

</body>
</html>



Aucun commentaire:

Enregistrer un commentaire