Hi Corvid Community!
How can I index into a dataset? On a button click, I would like to display one word from that dataset.
To better put the question into context, this is for a game where multiple users submit words into a dataset. On the click of this button, a random word would be chosen from that dataset (named ‘wordslist’) and displayed on the website.
I tried to program the onClick function but I get the error “save operation failed: DatsetError: Some of the elements validation failed”. I have also connected the button and the text box to the dataset as well as the button’s action to ‘submit’.
Here is what I have tried:
export function pickaword(event) {
//Add your code for this event here:
console.log(wordslist)
var randomNumber = Math.floor(Math.random()* wordslist.length));
document.getElementByID("#randworddisplay").value = wordslist[randomNumber]
}
Thank you in advance for any suggestions and advice!