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

234
Views
Función de llamada solo una vez después de 60 segundos

Tengo una función que calcula las palabras de los usuarios por minuto (ppm), solo debe llamarse una vez después de 60 segundos. En este momento estoy usando declaraciones if y setTimeout, pero no obtengo el resultado deseado.

lógica palabras por minuto

 function wordsdPerMinute() { if (userInput.toLocaleLowerCase() + ', ' == wordArray[wordCount]) { set_wordCount(wordCount + 1) } if (functionCounter == 0) { let timeOutID = setTimeout(() => { set_funcitonCounter(functionCounter + 1) alert('Times up!, press "Check your highscore!" downbelow') }, 60000) clearTimeout(timeOutID) } else { set_funcitonCounter(functionCounter - 1) wpmCounter() } } function wpmCounter() { countWPM = (wordCount + 1) / 60; highscore.push(countWPM) highscore.sort(function(a,b) {return ba}) }

como se llama la funcion

 <TextInput style={styles.inputText} onChangeText={set_userInput} value={userInput} onKeyPress={(event) => { if (event.nativeEvent.key == ' ') { wordsdPerMinute() } () => set_reset(initialState) }}

El resultado que obtengo es que wpmCounter() se ejecuta tantas veces como se llama después de 60 segundos. ¿Cómo puedo llamar a la función wpmCounter() solo una vez después de 60 segundos?

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!