Looking for help with my JavaScript code:
var wordSelection = [
{ 'word': "Pomme", "gender": "m" },
{ "word": "Banane", "gender": "f" },
{ "word": "Ananas", "gender": "m" },
{ "word": "Chat", "gender": "f" },
{ "word": "Chien", "gender": "m" },
{ "word": "Poisson", "gender": "f" }
];
function randomWord(){
var chosenWord = wordSelection[Math.floor(Math.random() * wordSelection.length)].word;
document.getElementById("word").innerHTML = chosenWord;
}
Is there a way to modify this code so that it only displays a random word (e.g. pomme, banane, ananas) or gender?
Currently, the output is [object Object] which is not what I want.
Thank you!