New course! Every coder should learn Generative AI!
Try a free lesson+ 6
How do I fix the null output in my code?
When you run my code and click cancel, it says Hi null instead of Hi. How do I fix the code for it to output Hi when the option "Cancel" is clicked. https://code.sololearn.com/W77SeGnOaQMS/?ref=app
5 Answers
+ 5
https://code.sololearn.com/W4WtyBr4hfnz/?ref=app
Fixed your code. Please see it.
+ 4
Wow, cool, thanks a million Prometheus ยฏ\_(ใ)_/ยฏ ๐ธ๐ฌ
+ 4
Ohhh, okay, once again, thanks thanks Prometheus ยฏ\_(ใ)_/ยฏ ๐ธ๐ฌ
+ 3
What happened is that when you use "user === true" you are expecting a 'true' boolean. What prompt gives you is a string so no way the condition will be fulfilled.
What I have done is to use "!user" as a conditional. If cancel is clicked then null is returned. Since null is equivalent to false,!null is true. Therefore it will activate your Hi
+ 3
You're welcome Mofey