Could someone please help me figure out why my code isn't functioning as expected? I'm trying to randomly select three names from a list and ensure that no name is repeated. While I believe I am on the right track, something seems to be missing. Any assistance would be greatly appreciated.
(function(){
var randomNames = function(){
var names = ["Jeffrey, Ronald, Superman, Lyndon, Alison"];
var myNames = [];
for (var i = 0; i < 3; i++){
var newNames = Math.floor(Math.random() * names.length);
var randomAllNames = names[newNames];
names.splice(newNames, 1);
myNames.push(names);
console.log(myNames);
}
return randomAllNames;
}; randomNames();
})();