Hello everyone I have such a problem:
I want at any given time, to present the current result. For example after a second, I want to display 60, after 2.5 seconds I want to display 85 and so these ...
I also want to display in the first second an array of 60 followed by a lot of zeros, because to the values after 60 I have not yet reached. And after 2.5 seconds you want to display such an array:
[60,85,0,0,0,0,0,0,0,0,0]
Because what after 85 I have not reached it yet
import React, { useEffect, useState } from "react";
import "./styles.css";
const Rep = {
TimeMove: [1, 2.5, 3, 3.5, 4.5, 5, 6, 10, 12, 13, 14, 15.5],
ScoreMove: [60, 85, 42, 60, 70, 80, 90, 100, 90, 40, 0, 20]
};
let i = 0;
export default function App() {
const [time, setTime] = useState("");
const [totalScore, setTotalScore] = useState([]);
useEffect(() => {
setTimeout(() => {
setTime(Rep.ScoreMove[i]);
i++;
}, Rep.TimeMove[i] * 1000);
}, [time]);
return
<div className="App">
{time}
{totalScore}
</div>;
}
I was unable to present the array of values I had reached