0

Javascript Verification practice

Hi, I'm at the Verification practice and I'm stuck, because in Javascript I can't create userinput based on what I've learned so far, because the error code refers to the fact that this is not a valid Javascript command… let pin = 1345; let userInput=prompt("Enter pin"); // log "Success" to the console if user input matches 1345 if(pin===1345) { console.log("Success"); } // log "Fail" if user input doesn't match the given pin else{ console.log("Fail"); }

1st Sep 2025, 4:04 PM
Neverland Jimmy
4 odpowiedzi
+ 2
maybe you need to convert the input to a Number. also, you should be comparing userInput with pin. not pin to 1345.
1st Sep 2025, 4:20 PM
Bob_Li
Bob_Li - avatar
0
You are a genius! Thank you! The solution: let pin = 1345; let userInput=Number(); // log "Success" to the console if user input matches 1345 if(pin<=Number()) { console.log("Success"); } // log "Fail" if user input doesn't match the given pin else{ console.log("Fail"); }
1st Sep 2025, 4:54 PM
Neverland Jimmy
0
the variable "pin" hold the "input". you are not supposed to use "prompt()". do NOT change what is stored in "pin". also, your comparison doesn't follow the instructions. it should only output "Success" when the pin matches exactly 1345, not when the number is smaller or equal.
1st Sep 2025, 4:59 PM
Lisa
Lisa - avatar
0
Neverland Jimmy, Sololearn doesn't support "prompt". You need to use "readline". https://sololearn.com/compiler-playground/cShz2ikf9hdu/?ref=app And you need write (Number(userinput)==pin) in if block.
1st Sep 2025, 5:00 PM
Mila
Mila - avatar