Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

188
Visualizações
How to test the current input text in javascript

i'm trying to test if the answer text is matching with the word that was declared in a object. But i can't test the current word because when i click i want first to test if the answer is correct but the variable is not already declared

here is my function 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;
    
}

here is my list

const listeWord = [
    {
        id: 1,
        word: 'escalope',
    },

    {
        id: 2,
        word: 'canapé'
    },

    {
        id: 3,
        word: 'table',
    },

    {
        id: 4,
        word: 'télé'
    }
]

here is my html code

<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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda