The output should get printed in my HTML doc:
const values = {
value1: {
name: 'VALUE 1'
},
value2: {
name: 'VALUE 2'
},
value3: {
name: 'VALUE3'
},
function choice(arr) {
return arr[Math.floor(Math.random() * arr.length)]
}
let randomchoice = choice(Object.values(values));
console.log(`result: ${randomchoice.name}`);
document.querySelector("#result").innerHTML = randomchoice;
<div id="result">
RESULT
</div>
Can someone please help me figure out why I can’t get the output printed? Or maybe if there’s another way to link the two codes.