Hi all, I’ve spent all day working on this timer, creating it to FCC’s exact specifications. I was shocked when I only passed ~15 of the 29 tests. I’ve been trying to figure out what’s wrong, but no matter what I do I don’t pass any further tests. The most frustrating thing, the clock definitely works as intended, at least to my human eyeballs. If anyone is able to offer any guidance – it would be BEYOND appreciated.
Hi! Thanks for the thoughtful response. Yes, I definitely intended to set session to ‘session’ when reset is clicked.
This is to meet the criteria in test 1:
When I click the element with the id of “reset”, any running timer should be stopped, the value within id=“break-length” should return to 5, the value within id=“session-length” should return to 25, and the element with id=“time-left” should reset to it’s default state.
Wow, thank you! You’re good at finding bugs. I’m going to spend time working on these issues and see if that helps. Thanks again for your time and help!!
Sorry, my understanding from your code was that session is a boolean, either true or false. setSession(session) is saying “if session is false, set session to false. If session is true, set session to true. Whatever value is in session, set session to that value.”
The time-left element should be displaying the “session” (string and counter), it’s default state. But as session is never reset to true explicitly in the reset, is that happening?
Ah! You are so right. I fixed it to set session to true. I think a big problem is that those actions aren’t all happening when reset is clicked. I have to click it twice for it to work properly.
I fixed the issues indicated here. I made it so you can’t edit the session/break length while the timer is running. I made sure the reset onClick works properly. I started a new pen because I was planning on starting over from scratch. new codepen
I ran the tests, I’m reading the results. Some of these, I truly do not understand why the tests aren’t passing. For example: " 2. When I click the element with the id of “break-decrement”, the value within id=“break-length” decrements by a value of 1, and I can see the updated value." Any ideas?
If you want to log state use a useEffect. Just add whatever state you want to log to the dependencies array and it will run every time the state is updated. Don’t rely on console.log that runs directly after calling a useState setter function.