SHARE
TWEET

Untitled

a guest May 27th, 2018 308 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var database = [
  2.   {
  3.     username: "Mike",
  4.     password: "pass123"
  5.   },
  6.   {
  7.     username: "John",
  8.     password: "pass555"
  9.   },
  10.   {
  11.     username: "Rome",
  12.     password: "passb99"
  13.   }
  14. ];
  15.  
  16. var newsFeed = [
  17.   {
  18.     username: "Robby",
  19.     timeline: "So tired of all that learning"
  20.   },
  21.   {
  22.     username: "Rick",
  23.     timeline: "Javascript is soooo cool!"
  24.   }
  25. ];
  26.  
  27. var userNamePrompt = prompt("What's your username?");
  28. var passwordPrompt = prompt("What's your password?");
  29.  
  30. function isUserValid(username, password) {
  31.   for (var i = 0; i < database.length; i++) {
  32.     if(database[i].username === username && database[i].password === password) {
  33.       return true;
  34.     }
  35.   }
  36.   return false;
  37. }
  38.  
  39. function signIn(username, password) {
  40.   if(isUserValid(username, password)) {
  41.     console.log(newsFeed);
  42.   } else {
  43.     console.log("You are not a user");
  44.   }
  45. }
  46.  
  47. signIn(userNamePrompt, passwordPrompt);
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top