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

141
Views
Cómo consolar cada valor de la matriz numérica con setInterval del valor como segundos Reactjs

let listofRandom = [ ]

consola cada valor que introduzco en esa matriz, con ciertos intervalos de tiempo

Por ejemplo: let listofRandom = [5, 1, 7]

Aquí el primer valor es 5, lo que significa que tiene que consolar el "5" cada 5 segundos y el siguiente valor es 1 tiene que consolar el "1" cada 1 segundo y luego consolar el "7" cada 7 segundos.

 let listofRandom = []; let generatedValues = ''; const addValue = () => { let value = Math.floor(Math.random() * 9) + 1; listofRandom.push(value); console.log(listofRandom) }; listofRandom.map((num) => { return setInterval(function () { generatedValue = generatedValue + num.toString(); console.log(generatedValue); }, num * 1000); }); return( <button onclick="addValue()">Add Value To Array </button>)
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

let listofRandom = [5, 1, 7]; listofRandom.map((num) => { setInterval(function() { console.log(num); }, num * 1000)});
about 4 years ago · Juan Pablo Isaza Report

0

 const [values, setValues] = useState([1, 5, 7]); const [count, setCount] = useState(0); useEffect(() => { let counter = count; const interval = setInterval(() => { if (counter >= values.length) { clearInterval(interval); } else { console.log(values[counter]); setCount((count) => count + 1); counter++; } }, values[counter] * 1000); return () => clearInterval(interval); }, [count]);
about 4 years ago · Juan Pablo Isaza Report
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!