I'm trying to randomize the words in a string using jquery but my code doesn't return anything.
This is what I have so far:
function makerand() {
var text = "";
var possible = "david, sarah, michelle, pedro";
text += possible.charAt(Math.floor(Math.random() * possible.length));
return text;
alert(text);
}
html:
<button onclick="makerand()">click me</button>
what I need to do is to randomize that string like so for example:
sarah, pedro, michelle, david
Could someone please advise on this?