+ 1

Help me to make it true.never I could to work with return statment.

https://code.sololearn.com/WC6IOEFuCzAC/?ref=app

5th Mar 2018, 7:22 PM
Sina
Sina - avatar
10 Answers
+ 1
I don't realy understand what you are trying to achive, can you ellaborate?
5th Mar 2018, 7:26 PM
Ilai Segev
Ilai Segev - avatar
+ 1
I want take a name from user and if the value of prompt was nothing it returns the promt again
5th Mar 2018, 7:28 PM
Sina
Sina - avatar
+ 1
I know but I want to do that with return to learn working with return
5th Mar 2018, 7:32 PM
Sina
Sina - avatar
+ 1
it's with do wile do{ var pr = prompt("Enter your name") } while(pr == "")
5th Mar 2018, 7:36 PM
Sina
Sina - avatar
5th Mar 2018, 7:38 PM
abcd abcd
0
Make a while loop using the statement (x!="") were x is the prompt
5th Mar 2018, 7:31 PM
Ilai Segev
Ilai Segev - avatar
0
make the return statememt value to a(), which will make the function repet until the user gives input
5th Mar 2018, 7:37 PM
Ilai Segev
Ilai Segev - avatar
0
For one your using an assignment operator in the 'if' statement. Secondly you need to have some sort of recursion weather it's a loop or having the function call itself. Here's an example using your code: x = ""; while(x == "") x = prompt("Enter your name"); return x;
5th Mar 2018, 7:44 PM
Lewis
Lewis - avatar
0
function a() { var x = prompt("Enter your name") if (x == "") { return a(); } } a() // Is this what you want? It'll keep asking for input till the input isn't nothing
5th Mar 2018, 7:56 PM
Marcus SĂžndergaard
Marcus SĂžndergaard - avatar
0
yes
5th Mar 2018, 8:37 PM
Sina
Sina - avatar