Skip to content

feat(m1): add solution exercise 024 completed #3010

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

carlolombardini
Copy link

No description provided.

phrase = 'fizz and buzz';
}

console.log( phrase );

Choose a reason for hiding this comment

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

Outside the function ;-)
Here: return phrase

}

function init(){
playFizzBuzz();

Choose a reason for hiding this comment

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

Here: console.log(playFizzBuzz) ;-)

return;
}

init();

Choose a reason for hiding this comment

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

In general, I advise not to complicate the solution and to solve it with at most three conditions.

Copy link
Author

Choose a reason for hiding this comment

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

Hi,
can you kindly check that everything is ok now and resolve the pr?

Thank you.

Copy link
Author

Choose a reason for hiding this comment

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

Hi, I made the changes for all comments, thank you.

Choose a reason for hiding this comment

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

This algorithm does not solve the problem correctly.
But at this point, I suggest you not change the code now.
Write the tests first and see if it really works as you would expect or not.
In short, correct it after testing it ;-)

…tants and the direct printing of value in exercise 024
phrase = 'fizz';
} else if ( i % 5 === 0){
phrase = 'buzz';
} else if ( i % 3 === 0 && i % 5 === 0){

Choose a reason for hiding this comment

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

Will this code ever run? ;-)

let phrase = i;

if ( i % 3 === 0 ){
phrase = 'fizz';

Choose a reason for hiding this comment

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

Hint: phrases += 'fizz' + '\n';

const length = 100;

for (let i = 1; i <= length; i++) {
let phrase = i;

Choose a reason for hiding this comment

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

The use of this additional variable phrase is not recommended.


}

phrases += i === length ? phrase : phrase + '\n';

Choose a reason for hiding this comment

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

This check is also not recommended.
It makes no sense to check 100 values ​​to remove the trailing '\n'.
Find a workaround to remove it ;-)

…meric value if the previous conditions are not satisfied, remove useless constant and variable, used replace function for phrases to remove last n occurence in exercise 024
return;
}

init();

Choose a reason for hiding this comment

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

This algorithm does not solve the problem correctly.
But at this point, I suggest you not change the code now.
Write the tests first and see if it really works as you would expect or not.
In short, correct it after testing it ;-)

… remainder 3 and 5 equal to 0 for first. added the test file to check if the function playFizzBuzz works correctly in exercise 024
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