Skip to content

Conversation

@denys-anokhin
Copy link

No description provided.

Copy link

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Summary

I’m requesting changes because two critical requirements are not met and they block correct functionality.

  • Initial state: On src/App.jsx line where useState is initialized, count starts at 0, but the requirement states the Increase sequence must begin 101, 102, ...; this implies the initial count must be 100 so the first Increase yields 101.
  • Increase logic/order: In src/App.jsx, the increase handler checks count % 5 === 0 before calling addOne() and may call add100() using stale state. The requirement is: first call addOne to add 1; then, based on the updated count, if it’s divisible by 5, call add100. This must avoid stale state by either computing newCount = count + 1 and checking newCount % 5 === 0, or by using a functional updater and performing the divisibility check on the updated value.

What you did well: UI structure, addOne and add100 use functional updaters and are correctly wired to their buttons.
Minor: Keep the code simple and avoid unnecessary checks; comments can note the required Increase sequence.
Please update the initial state to 100 and fix the Increase handler’s order/check so tests for the sequence (101, 102, 103, 104, 105, 206, …) pass. Keep going—you’re close!


✨ 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

  1. Rate AI review example

  2. Re-request AI review example

  3. Add AI review comments example


export const App = () => {
const [count] = useState(0);
const [count, setCount] = useState(0);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This violates the checklist requirement: "The sequence of values produced by repeatedly clicking "Increase" must match: 101, 102, 103, 104, 105, 206, 207, 208, 209, 210, 311, ..." — the initial state is 0 here, so the first Increase cannot produce 101. Set the initial count to 100 instead of 0 so the sequence starts at 101.

// eslint-disable-next-line no-shadow
setCount(count => {
return count + 1;
});

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This violates the checklist requirement: "The 'Increase' button must: Call addOne to increase the count by 1. After that, if the resulting count is divisible by 5, additionally call add100 to increase the count by 100 more." The current increase implementation checks count % 5 === 0 before calling addOne() and may call add100() using stale state and in the wrong order. Change the logic so the +1 is applied first and the divisibility check is performed on the updated value (use a functional updater to avoid stale state or restructure so the check runs after the +1).

Copy link

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Summary

I’m requesting changes because two critical requirements are not met, which will break the expected Increase sequence and likely fail tests.

  • Issue 1 (src/App.jsx line where state is initialized): useState(0) starts at 0, but the spec requires the first Increase to produce 101. Initialize with useState(100) so the first press yields 101.
  • Issue 2 (src/App.jsx in the increase handler): The logic checks divisibility before adding 1, which violates the requirement “add 1, then if the updated value is divisible by 5, add 100.” Fix by first computing the next value (e.g., const next = count + 1), applying addOne(), and then conditionally applying add100() if next % 5 === 0. Alternatively, use a single functional setCount(prev => { const next = prev + 1; return next % 5 === 0 ? next + 100 : next; }).

What’s good: addOne and add100 are correctly implemented and the UI wiring looks correct. After making these two fixes, the Increase sequence should be 101, 102, 103, 104, 105, 206, 207, … and tests should pass. Keep up the good work—these are targeted changes to align with the spec.


✨ 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

  1. Rate AI review example

  2. Re-request AI review example

  3. Add AI review comments example


export const App = () => {
const [count] = useState(0);
const [count, setCount] = useState(0);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This violates the requirement that the first Increase should produce 101. The description expects the Increase sequence: "So the third button should count like this: 101, 102, 103, 104, 105, 206, 207, ..." Currently useState is initialized to 0. Initialize the state to 100 (e.g. useState(100)) so the first Increase yields 101 as required.

Copy link

@mateacademy-ai-mentor mateacademy-ai-mentor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Review Summary

Here is my approval to help you progress while learning. You set up the React component cleanly with clear handlers and proper button wiring—nice job using functional updates for addOne and add100.

However, two critical fixes are needed for the Increase behavior:

  • In src/App.jsx, initialize the state to 100 (e.g., useState(100)) so the first Increase press yields 101 as required.
  • In src/App.jsx, the increase handler currently checks count % 5 === 0 using the old value. The requirement says: first add 1, then if the updated value is divisible by 5, add 100. Use a single functional update that computes next = prev + 1 and then conditionally adds 100 based on next % 5 === 0 to avoid stale state.

These changes will produce the correct sequence: 101, 102, 103, 104, 105, 206, ... Keep going—you’re very close!


✨ Please rate this review in the Platform's notification center1. I will be grateful for your feedback! ✨

Footnotes

  1. Rate AI review example


export const App = () => {
const [count] = useState(0);
const [count, setCount] = useState(0);

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This violates the requirement that the first Increase press results in 101. Initialize the counter to 100 (e.g., useState(100)) so the first Increase yields 101. Requirement: "The Increase button must produce the sequence: 101, 102, 103, 104, 105, 206, ..."

Comment on lines +21 to 25
addOne();

if (count % 5 === 0) {
add100();
}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The increase handler calls addOne() and then checks if (count % 5 === 0), which tests the old value (count) instead of the updated value. This violates: "It first adds 1... After adding 1, if the updated count is divisible by 5, it additionally adds 100." Use a single functional update to avoid stale state, for example: setCount(prev => { const next = prev + 1; return next % 5 === 0 ? next + 100 : next; }) so the divisibility check uses the new value.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants