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

All tests are completed #2378

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Conversation

YevaDrach
Copy link

No description provided.

Comment on lines +11 to +23
function getSum(number) {
return function(value) {
count++;

const result = value + number;

if (count % 2 === 0 && count > 3) {
return 'Bzzz... Error!';
} else {
return result;
}
};
}

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) {

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) {

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.

Copy link

@vadiimvooo vadiimvooo left a comment

Choose a reason for hiding this comment

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

Well done

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.

3 participants