+ 3

Please help me fix my JS code

Any help will be appreciated Here is the code https://code.sololearn.com/W2izb2c5Q4us/#html

27th Apr 2017, 9:22 PM
Abdel
Abdel - avatar
7 Respuestas
+ 1
Like this one? Code: function yourName() { var b = false while(b == false) { userInput = prompt("What is your name? ") if(userInput == "") { alert("You didn't input anything!"); continue } find = userInput.replace(/[\D]/g, '') if(find != "") { alert("Your didn't contain a number!") continue } b = true } alert("Hey there "+userInput+" !") }
27th Apr 2017, 9:58 PM
Thomas Hj
Thomas Hj - avatar
+ 4
try/catch block
27th Apr 2017, 9:51 PM
Haris
Haris - avatar
+ 4
Thank you @Thomas Hj this exactly what i wanted to code I really a appreciate you all
27th Apr 2017, 11:05 PM
Abdel
Abdel - avatar
+ 3
I want to alert the user when he/she enters a digit (0-9)
27th Apr 2017, 9:24 PM
Abdel
Abdel - avatar
27th Apr 2017, 11:29 PM
Abdel
Abdel - avatar
+ 2
You need to match the regex using decimal = userInput.match(yourRegEx)
27th Apr 2017, 9:55 PM
Bebida Roja
Bebida Roja - avatar
+ 2
Your welcome :) I forget to add ' || userInput == null ' but I think you know where to be added in.
28th Apr 2017, 10:09 AM
Thomas Hj
Thomas Hj - avatar