can someone tell me whats wrong with my code? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

can someone tell me whats wrong with my code?

function password(){ var p = prompt("please enter your password:"); if(p != 1234){ alert("incorrect password!"); } else if(p == "i want a new password"){ var v = prompt("please enter your old password"); if(v != p){ alert("incorrect password"); } else{alert("password set")} } else{ alert("correct password!"); } } password();

10th Jul 2020, 12:14 PM
chris ziogas
chris ziogas - avatar
2 Answers
+ 1
not v != p because in that case, p is a string "i want a new password" and you want v not equal old password (1234)
10th Jul 2020, 12:19 PM
Gordon
Gordon - avatar
0
thatmust have been the answer but ive tested it and couldnt make it work, so i am stopping that experiment
10th Jul 2020, 2:33 PM
chris ziogas
chris ziogas - avatar