Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

186
Views
Cómo probar el texto de entrada actual en javascript

Estoy tratando de probar si el texto de la respuesta coincide con la palabra que se declaró en un objeto. Pero no puedo probar la palabra actual porque cuando hago clic, primero quiero probar si la respuesta es correcta pero la variable aún no está declarada.

aquí está mi función onClick

 function testerField() { // I'd like to test if the user's answer properly // match the word before shuffling var test = document.getElementById('wordfinal').value; // random func var random = getRandomInt(listeWord.length) // get the word from js object var stock = listeWord[random].word // shuffle the word var afficher = stock.shuffle() // display document.getElementById('word').value = afficher; }

aquí está mi lista

 const listeWord = [ { id: 1, word: 'escalope', }, { id: 2, word: 'canapé' }, { id: 3, word: 'table', }, { id: 4, word: 'télé' } ]

aquí está mi código html

 <div class="main_content"> <form onsubmit="submitPrevent(event)"> <p class="phraseForm">Find the Word</p> <input type="integer" class="formInt" id="word" > <p class="phraseForm">Word</p> <input type="integer" class="formInt" id="wordfinal" > <div id="sub"> <input type="submit" value='Ok' class="envoyer" onclick="testerField()"> </div>
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!