-
Notifications
You must be signed in to change notification settings - Fork 131
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
base: main
Are you sure you want to change the base?
feat(m1): add solution exercise 024 completed #3010
Conversation
phrase = 'fizz and buzz'; | ||
} | ||
|
||
console.log( phrase ); |
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.
Outside the function ;-)
Here: return phrase
} | ||
|
||
function init(){ | ||
playFizzBuzz(); |
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.
Here: console.log(playFizzBuzz)
;-)
return; | ||
} | ||
|
||
init(); |
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.
In general, I advise not to complicate the solution and to solve it with at most three conditions.
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.
Hi,
can you kindly check that everything is ok now and resolve the pr?
Thank you.
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.
Hi, I made the changes for all comments, thank you.
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.
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){ |
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.
Will this code ever run? ;-)
let phrase = i; | ||
|
||
if ( i % 3 === 0 ){ | ||
phrase = 'fizz'; |
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.
Hint: phrases += 'fizz' + '\n';
const length = 100; | ||
|
||
for (let i = 1; i <= length; i++) { | ||
let phrase = i; |
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 use of this additional variable phrase
is not recommended.
|
||
} | ||
|
||
phrases += i === length ? phrase : phrase + '\n'; |
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.
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(); |
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.
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
No description provided.