While it's not completely bad to put the follow up to if statement on the same line, it's rather more clear if you put it on the next line and use closures as well. Particularly when you're not using ; as much.
It's always better to give the user some feedback in case of no-operation (no-op). You can make this more automatic by adding validation on the input field in your html file.
Try also implementing the reset case if you have the time, that can be challenging.
https://github.com/abedaarabi/hyf-homework/blob/4563ddf985b9e5e71d57846701b61c55d1e34367/javascript/javascript2/main.js#L15
While it's not completely bad to put the follow up to
if
statement on the same line, it's rather more clear if you put it on the next line and use closures as well. Particularly when you're not using;
as much.https://github.com/abedaarabi/hyf-homework/blob/4563ddf985b9e5e71d57846701b61c55d1e34367/javascript/javascript2/main.js#L12
It's always better to give the user some feedback in case of no-operation (
no-op
). You can make this more automatic by adding validation on theinput
field in yourhtml
file.Try also implementing the reset case if you have the time, that can be challenging.