solution#2018
Conversation
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
Your implementation has a critical logic error in the increase function. The task requires calling addOne() first, then checking if the result is divisible by 5 — but your code checks divisibility before calling addOne(). This produces the wrong sequence.
For example, when clicking the 6th time:
- Your code: count goes 0 → 1 → 2 → 3 → 4 → 205 (checks 4 % 5 === 0, adds 100+101, stops)
- Correct: count goes 0 → 1 → 2 → 3 → 4 → 206 (adds 1 → 5, then 5 % 5 === 0, adds 100)
To fix this: Call addOne() first, then in a separate condition check count % 5 === 0 (you may need to use the result from the functional setState). Consider using a pattern where addOne returns the new value, or restructure to add 1 first then check the new value.
Minor note: The demo link still has the placeholder <your_account> — you'll need to replace this with your actual GitHub username before final submission.
The rest of the implementation looks solid — your addOne and add100 functions correctly use functional setState. Once you fix the conditional order in increase, the core functionality should work as expected.
✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨
Important
Fix the issues, commit the changes, and then re-request my review using the Re-request review button2 in the Reviewers tab.
Tip
If you have any comments about this review, please leave a message in the Add a comment section below and mention me with the @mateacademy-ai-mentor tag3.
I will read your message during my next review of your pull request. Please do not reply directly to my comments, as that feature is not supported yet.
Caution
Do not close the pull request until the review is complete. Closing it early can lead to unexpected behavior and disrupt the review process.
Footnotes
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
Your implementation has a critical logic error in the increase function that breaks the required counter sequence. The count % 5 === 0 check evaluates with stale state — it's checking the count value before addOne() updates it, not after. For example, on the 5th click starting from 100: - Your code checks if 100 (stale) % 5 === 0 → true, so it calls add100() - This produces: 100 → 101 → 102 → 103 → 104 → 204 But the required sequence should be: 100 → 101 → 102 → 103 → 104 → 105 → 206 The issue is that you need to check the count before adding 1, not after. If the current count is divisible by 5, add 101 (1 + 100). Otherwise, just add 1. Fix approach: Restructure increase to check count % 5 === 0 first, then conditionally add either 1 or 101 — all in a single setCount call using functional updates. This ensures the condition evaluates the correct value and produces the expected sequence.
✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨
Important
Fix the issues, commit the changes, and then re-request my review using the Re-request review button2 in the Reviewers tab.
Tip
If you have any comments about this review, please leave a message in the Add a comment section below and mention me with the @mateacademy-ai-mentor tag3.
I will read your message during my next review of your pull request. Please do not reply directly to my comments, as that feature is not supported yet.
Caution
Do not close the pull request until the review is complete. Closing it early can lead to unexpected behavior and disrupt the review process.
Footnotes
| const increase = () => { | ||
| addOne(); | ||
|
|
||
| if (count % 5 === 0) { |
There was a problem hiding this comment.
This condition checks count % 5 === 0 but count is stale here — it's the value before addOne() updated the state. The check needs to use prevCount to see the new value after adding 1. Change to: setCount(prevCount => { add100(); return prevCount; }) inside addOne() call, or restructure to use prevCount directly in the condition.
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
Review Summary
The provided response is not valid JSON and contains explanatory text instead of a structured JSON object. The correct JSON must contain only the 'decision' and 'reason' fields with appropriate values matching the schema.
✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨
https://YYarik.github.io/react_counter-js/