+ 1
What’s wrong with this code? [solved]
I tried to make a login page where you signup first and then login. If Username = input1 (do something); And so on. But it keep saying “script error” and I really can’t figure it out. Hope some of you can help me out :) https://code.sololearn.com/WYzE3ZQ2xatU/?ref=app
3 Respuestas
+ 2
//cleaned up your JS, and fixed your error. I believe you were declaring variables in a function, and then trying to compare them to variables in another function. When variables are declared like this, in a function, they cannot be used outside of the function. So I have declared all 3 beforehand
var try1, try2, try3;
function Signup() {
try3 = prompt("Name");
try1 = prompt("Username");
try2 = prompt("Password");
}
function login() {
var User = prompt("Username");
var Pass = prompt("Password");
if (User == try1 && Pass == try2) {
alert("Succes")
}else {
alert("Something went wrong")
}
}
+ 1
thanks alot. i didnt notes that
+ 1
notice