What I am trying to now is to input data thru prompt() and when the value for each variable is accepted, it will pass to function, and if met the conditions, it will be logged to console, if not different log will be displayed. I am also not sure how should be arguments in function invocation should be packaged since I declared prompt() first before the function.
So, here's what my code looks like. Also, there's an error thrown for the length, I don't know why.
let firstName = (prompt("First Name"));
let lastName = (prompt("Last Name"));
let emailAdd = (prompt("Email Address"));
let password = (prompt("Password"));
let confirmPassword = (prompt("Confirm Password"));
function getInfo(firstName, lastName, emailAdd, password, confirmPassword){
if (firstName.length !== 0 && lastName.length !== 0 && emailAdd.length !== 0 && password !== 0 && confirmPassword !== 0 && password.length >= 8 && password === confirmPassword){
console.log("First Name: " + firstName);
console.log("Last Name: " + lastName);
console.log("Email Address: " + emailAdd);
console.log("Password: " + password);
console.log("confirm Password: " + confirmPassword);
console.log("Information accepted.")
} else {
console.log("Please fill in your information.")
}
}
getInfo();
Aucun commentaire:
Enregistrer un commentaire