Solution#4261
Conversation
mateacademy-ai-mentor
left a comment
There was a problem hiding this comment.
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
| export const Sum = ({ a = 0, b = 0 }) => ( | ||
| <p> | ||
| Sum of {a} and {b} is {a + b} |
There was a problem hiding this comment.
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}}
| @@ -1,13 +1,15 @@ | |||
| import React from 'react'; | |||
| import './App.scss'; | |||
|
|
|||
There was a problem hiding this comment.
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.
| <p>Sum of 0 and 0 is 0</p> | ||
| <Sum a={2} b={3} /> | ||
| <Sum a={-5} b={5} /> | ||
| <Sum a={10} b={0} /> |
There was a problem hiding this comment.
According to requirements, this should be <Sum a={10} /> (just a=10, b should default to 0)
| <Sum a={2} b={3} /> | ||
| <Sum a={-5} b={5} /> | ||
| <Sum a={10} b={0} /> | ||
| <Sum a={0} b={5} /> |
There was a problem hiding this comment.
According to requirements, this should be <Sum b={5} /> (just b=5, a should default to 0)
[x] DEMO LINK
[x ]Create a
Sumcomponent acceptingaandbprops and rendering a paragraph with a text likeSum of 2 and 1 is 3. Replace numbers with actual values. If theaorbprops are not passed, set them to0.[x] The
Appshould contain the nextSumcomponents:[x] -
a = 2andb = 3;[x] -
a = -5andb = 5;[x] - just
a = 10;[x] - just
b = 5;[x] - no params at all.