How do I fix the null output in my code? | Sololearn: Learn to code for FREE!
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

24th Jun 2019, 3:15 AM
eMBee
eMBee - avatar
5 Answers
+ 5
https://code.sololearn.com/W4WtyBr4hfnz/?ref=app Fixed your code. Please see it.
24th Jun 2019, 3:18 AM
๐Ÿ‘‘ Prometheus ๐Ÿ‡ธ๐Ÿ‡ฌ
๐Ÿ‘‘ Prometheus ๐Ÿ‡ธ๐Ÿ‡ฌ - avatar
24th Jun 2019, 3:20 AM
eMBee
eMBee - avatar
+ 4
Ohhh, okay, once again, thanks thanks Prometheus ยฏ\_(ใƒ„)_/ยฏ ๐Ÿ‡ธ๐Ÿ‡ฌ
24th Jun 2019, 3:22 AM
eMBee
eMBee - avatar
+ 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
24th Jun 2019, 3:20 AM
๐Ÿ‘‘ Prometheus ๐Ÿ‡ธ๐Ÿ‡ฌ
๐Ÿ‘‘ Prometheus ๐Ÿ‡ธ๐Ÿ‡ฌ - avatar
+ 3
You're welcome Mofey
24th Jun 2019, 3:22 AM
๐Ÿ‘‘ Prometheus ๐Ÿ‡ธ๐Ÿ‡ฌ
๐Ÿ‘‘ Prometheus ๐Ÿ‡ธ๐Ÿ‡ฌ - avatar