Skip to content

Solution#4261

Open
ValentynaBahyrly wants to merge 1 commit into
mate-academy:masterfrom
ValentynaBahyrly:develop
Open

Solution#4261
ValentynaBahyrly wants to merge 1 commit into
mate-academy:masterfrom
ValentynaBahyrly:develop

Conversation

@ValentynaBahyrly
Copy link
Copy Markdown

[x] DEMO LINK

[x ]Create a Sum component accepting a and b props and rendering a paragraph with a text like Sum of 2 and 1 is 3. Replace numbers with actual values. If the a or b props are not passed, set them to 0.

[x] The App should contain the next Sum components:
[x] - a = 2 and b = 3;
[x] - a = -5 and b = 5;
[x] - just a = 10;
[x] - just b = 5;
[x] - no params at all.

Copy link
Copy Markdown

@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

Your solution is approved. All functional requirements are met, tests pass, and the Sum component correctly handles props with defaults and renders the expected output. However, there are two style improvements worth noting for future reference: 1. Use template literals for string interpolation - CHECKLIST ITEM #2 requires using template literal syntax inside JSX content. Instead of multiple JSX expressions: Sum of {a} and {b} is {a + b} Use a single template literal: {Sum of ${a} and ${b} is ${a + b}}. 2. Avoid redundant default props - When calling with no params or just one param, you don't need to explicitly pass a={0} or b={0}. The component already defines these defaults, so calling or works without the extra props. These are style-level suggestions rather than functional issues—your implementation is correct and complete.


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

Footnotes

  1. Rate AI review example

Comment on lines +1 to +3
export const Sum = ({ a = 0, b = 0 }) => (
<p>
Sum of {a} and {b} is {a + b}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This violates checklist item #2: Use string interpolation inside tag content. The content should use template literal syntax: {Sum of ${a} and ${b} is ${a + b}}

Comment thread src/App.jsx
@@ -1,13 +1,15 @@
import React from 'react';
import './App.scss';

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Checklist item #2 violation: Use string interpolation (template literals) inside tag content. Use {`Sum of ${a} and ${b} is ${a + b}`} instead of separate expressions.

Comment thread src/App.jsx
<p>Sum of 0 and 0 is 0</p>
<Sum a={2} b={3} />
<Sum a={-5} b={5} />
<Sum a={10} b={0} />
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

According to requirements, this should be <Sum a={10} /> (just a=10, b should default to 0)

Comment thread src/App.jsx
<Sum a={2} b={3} />
<Sum a={-5} b={5} />
<Sum a={10} b={0} />
<Sum a={0} b={5} />
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

According to requirements, this should be <Sum b={5} /> (just b=5, a should default to 0)

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