Please resolve me How enter "Name" with Javascript? Not applies Name to enter | Sololearn: Learn to code for FREE!

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; } }

5/16/2020 7:18:22 AM

Reezy

2 Answers

New Answer

+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()

0

Thank you