Tell us what’s happening:
Hey everyone, so I’m having a hard time passing the Timer tests for the Pomodoro Clock. From manual testing it seems to work just fine, but it is failing Timer tests 1, and 9-15. I think the error might be residing in this function which controls the timer counting down and switching sessions.
Your code so far
countDown(){
if(this.state.paused === false){
clearInterval(this.cycle);
this.setState({
paused: true
})
}
else{
this.setState({
paused: false
});
this.cycle = setInterval(() =>{
if(this.state.timer === 0){
this.setState({
session: (this.state.session === 'Session') ? 'Break' : 'Session',
timer: (this.state.session === 'Session') ? (this.state.breakLength * 60) : (this.state.sessionLength * 60)
});
//this.switchSession();
this.beep();
}
else{
this.setState({
timer: this.state.timer - 1
})
}
}, 1000)
}
}
Here is a link to my CodePen for the project: https://codepen.io/CyVy/pen/qBbzqqW?editors=0010
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.105 Safari/537.36
.
Challenge: Build a Pomodoro Clock
Link to the challenge:
https://www.freecodecamp.org/learn/front-end-libraries/front-end-libraries-projects/build-a-pomodoro-clock