Quiero hacer un sitio web de verdad o reto donde la gente pueda jugar verdad o reto en línea, pero me he enfrentado a algunos problemas.
Código HTML
<button id="truth"> +t </button> <div><p id="game">+t for English Truth, +d For English Dare, +tb For Bangla Truth, +db for Bangla Dare</p></div>aquí está mi código js
const t = [ "If you could be invisible, what is the first thing you would do?", "What is a secret you kept from your parents?", "What is the most embarrassing music you listen to?", "What is one thing you wish you could change about yourself?", "Who is your secret crush?", ]; document.getElementById('truth').addEventListener('click', function(){ const truth = t[Math.floor(Math.random() * t.length)]; const games = document.getElementById('game'); console.log(truth) games.innerText(truth) })pero cuando hice clic en el botón dice Uncaught TypeError: games.innerText no es una función
¿Ahora que puedo hacer?
dice que games.innerText no es una función que toma un parámetro. El uso correcto del método innerText es:
games.innerText = truth;igual que HTML interno
echa un vistazo a los documentos de texto interno de MDN