This website is amazing! I've interacted with so many awesome people here!
Currently, I have successfully implemented code to get one random name from an array. However, I now want to display three different names each time, and I'm facing a roadblock.
Is there anyone out there who can help me out and showcase their expertise? I would greatly appreciate it! <3
The JavaScript Code
<script>
window.onload = funkytown;
function funkytown() {
document.getElementById("btn").onclick = name;
}
function name() {
var students = ["Mike","Nick","Slagathor","Banana","Rick","Astley","Rock","JW","pronax"];
var randomize = students.splice(Math.floor(Math.random() * students.length), 1);
var html = "Random names: ";
document.getElementById("text").innerHTML = html + randomize;
}
</script>
The HTML Structure
<span id="text"></span>
<input type="button" id="btn" value="Randomize!" />