I am a beginner at programming and I am trying to make a clock project.
I am just at the start of it but my code is already not working. At this point of the project what I am trying to do is just to have the timer running when I click on play.
It would be so nice if I could get a bit of help there.
Here is my code :
import React, { useState } from 'react';
import ReactDOM from 'react-dom'
function App(props) {
let minutes = 25
let seconds = 0
function clockmecanics () {
if (seconds===0) {
seconds = 60
minutes --
}
seconds --
}
function updater () {
while (minutes>0){
setTimeout(clockmecanics(),1000)
}
}
return (
<div>
<h1> CLOCK </h1>
<h1> Breaklength : 5 </h1>
<button> + </button>
<button> - </button>
<h1> Sessionlength : 25 </h1>
<button> + </button>
<button> - </button>
<h1> {minutes}:{seconds} </h1>
<button onClick={()=> updater ()}>PLAY</button>
<h2> </h2>
</div>
)
}
ReactDOM.render(
<App />,
document.getElementById('container')
);