0

Please resolve me How enter "Name" with Javascript? Not applies Name to enter

Example: function myFunction( ){ var retVal=prompt("enter your name","your name here"); if(retVal === true) { document.write("what is your name?"); return true; } else { document.write("your name here:" + "retVal"); return false; } }

16th May 2020, 7:18 AM
Reezy
Reezy - avatar
2 Réponses
+ 2
prompt returns string entered by user or returns `null` if cancel is pressed. You should check whether returned value is null or not (don't check against `true`) if(retVal === null) { //your code } Also don't forget to call method: myFunction()
16th May 2020, 7:28 AM
🇮🇳Omkar🕉
🇮🇳Omkar🕉 - avatar
0
Thank you
17th May 2020, 7:38 PM
Reezy
Reezy - avatar