-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
All tests are completed #2378
base: master
Are you sure you want to change the base?
All tests are completed #2378
Conversation
function getSum(number) { | ||
return function(value) { | ||
count++; | ||
|
||
const result = value + number; | ||
|
||
if (count % 2 === 0 && count > 3) { | ||
return 'Bzzz... Error!'; | ||
} else { | ||
return result; | ||
} | ||
}; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The inner function returned by getSum
should not be named. You can simply return an anonymous function.
|
||
const result = value + number; | ||
|
||
if (count % 2 === 0 && count > 3) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should use one variable for counting function calls. Here, you are using count
correctly to keep track of the calls to the returned function.
|
||
const result = value + number; | ||
|
||
if (count % 2 === 0 && count > 3) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consider combining the conditions in the if statement to avoid nesting ternary operators or multiple if-else statements. Since you're only checking one condition, it's not necessary to use an else statement; you can return result
directly after the if block.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well done
No description provided.