Can someone help me figure out how to randomly select just one word from a block of text using JavaScript?
Here's the code I've been working with:
function someFunction() {
// need help here
var word;
$.ajax({
async: false,
type: 'GET',
url: link,
success: function(data) {
word = getWord(data); // retrieve random word from data
}
});
}
function getWord(text) {
// could anyone assist me with this?
}
I believe this should be a straightforward fix. Appreciate any assistance!