Skip to content

Instantly share code, notes, and snippets.

@sidwebworks
Created February 1, 2021 18:17
Show Gist options
  • Save sidwebworks/50871cc3d1d7fe75be577da768bb1a34 to your computer and use it in GitHub Desktop.
Save sidwebworks/50871cc3d1d7fe75be577da768bb1a34 to your computer and use it in GitHub Desktop.
Learning Javscript
var dataBase = [{
username: "User 1",
password: "pass@user1"
},
{
username: "User 2",
password: "pass@user2"
},
{
username: "User 3",
password: "pass@user3"
},
{
username: "User 4",
password: "pass@user4"
}
]
var timeLine = [
{
name: "User1",
message: "Hey I am user 1"
},
{
name: "User2",
message: "Hey I am user 2"
},
{
name: "User 3",
message: "Hey I am user 3"
},
{
name: "User 4",
message: "Hey I am user 3"
}
]
function checkPass(user, pass) {
for (var i = 0; i < dataBase.length; i++) {
if (user === dataBase[i].username && pass === dataBase[i].password) {
console.log('Success');
return true;
}
}
return false;
}
function signIn(user, pass) {
if (checkPass(user, pass)) {
console.log('Welcome to Facebook');
console.table(timeLine);
} else {
return alert('Sorry Wrong username or password');
}
}
do {
var userInput = prompt('What would you like to do?')
if (userInput === "login") {
var emailId = prompt('Your username');
var passWord = prompt('Your password');
signIn(emailId, passWord);
}
}
while (userInput !== "exit");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment