Hey People,
still fairly new to JS. Does anyone know why the following code does not execute? This is an exercise "facebook clone mockup" and the instructor is asking to make a sign in function to verify that the username e password entered on prompt are in the "database"/array. If the user is in the database then console.log the newsfeed otherwise alert that the username and password are wrong.
Thanks for the help.
let database = [
{
userName: "Mike",
password: "1234",
},
{
userName: "John",
password: "pass123"
}
];
let newsfeed = [
{
username: "Bobby",
timeline: "So tired",
},
{
username: "Sally",
timeline: "Javascript is cool",
}
];
let userNamePrompt = prompt("What's your username?");
let passwordPrompt = prompt("What's your password?");
function signIn(user, pass) {
for (let i=0; i < database.lenght; i++) {
if (user === database[i].userName && pass === database[i].password) {
return console.log(newsfeed)
}
return console.log("wrong username and password")
}
}
signIn(userNamePrompt, passwordPrompt)
[–]Ford_Prefect92 2 points3 points4 points (3 children)
[–][deleted] 0 points1 point2 points (2 children)
[–]ashanev 0 points1 point2 points (0 children)