Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solution #2386

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Solution #2386

wants to merge 3 commits into from

Conversation

1luki9901
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.

Great job on your Pull Request! There are no critical issues, and it looks like you're following good coding practices. Just a friendly reminder to avoid nesting ternary operators in the future, but that's not a blocker for approval. Keep up the good work! 👍💻

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

Comment on lines 15 to 20
return (operator) => {
if (callCounter > 3 && callCounter % 2 === 0) {
return 'Bzzz... Error!';
}

return num + operator;

Choose a reason for hiding this comment

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

[CODE STYLE] - Don't nest ternary operators. You're using an if statement inside a returned function which is okay, but make sure to avoid nesting ternary operators as per the code style guide.

const getSum = (num) => {
callCounter++;

return (operator) => {

Choose a reason for hiding this comment

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

[CODE STYLE] - You don't need to name functions if you return them right away. In this case, the function returned from getSum is anonymous as it should be, which aligns with the code style guide.

@@ -7,6 +7,21 @@

function makeRobotAccountant() {
// write code here
let callCounter = 0;

Choose a reason for hiding this comment

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

[CODE STYLE] - You should use one variable for counting function calls, which you have correctly implemented here with callCounter.

Comment on lines 16 to 20
if (callCounter > 3 && callCounter % 2 === 0) {
return 'Bzzz... Error!';
}

return num + operator;

Choose a reason for hiding this comment

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

[CODE STYLE] - DRY. When you do similar logic, try to combine conditions. In this case, you have separated the logic for error handling and returning the sum, which is appropriate as they are distinct behaviors.

Copy link

@Zibi95 Zibi95 left a comment

Choose a reason for hiding this comment

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

Hey. This can be simplified by directly returning functions.

const getSum = (num) => {
callCounter++;

return (operator) => {
Copy link

Choose a reason for hiding this comment

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

its a second number not operator that you provide through params.

let callCounter = 0;

const getSum = (num) => {
callCounter++;
Copy link

Choose a reason for hiding this comment

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

callCounter should be incremented inside the second, deeper function.

@@ -7,6 +7,21 @@

function makeRobotAccountant() {
// write code here
let callCounter = 0;

const getSum = (num) => {

Choose a reason for hiding this comment

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

you can return getSum function right away instead of declaring it first and then returning it ;)

Copy link

@Zibi95 Zibi95 left a comment

Choose a reason for hiding this comment

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

Good job!

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.

4 participants