Try this, Its running
var database = [{username: "Sean", password: 1995}];
var newsFeed = [{username: "Tanya", timeline: "She says it very cool"}, {username: "Misha", timeline: "Misha is working at sphere of railways"}];
var askUsernameByPrompt = prompt("What is your username");
var askPasswordByPrompt = prompt("What is your password");
function signIn(user, pass){
if(user === database[0].username && pass === database[0].password) {console.log(newsFeed);}
else{alert("Sorry, username or password!");}
}
signIn(askUsernameByPrompt, askPasswordByPrompt);
You just made a little mistake in if condition, for strict equality comparison in JavaScript, we write ===
that checks for both type and content but you mistakenly typed ====
which is wrong syntax. For more information on comparison operator check its official documentation here.
2
solved The function is not being called by browser when you reload the page? What is wrong? [closed]