title: "How one function parameters connects with another function parameters in javascript?"
body: <p>I was creating this facebook user login system basic logic in javascript. The logic is not my own but I am learning logics from these kind of codes. it is the logic of my online javascript teacher I got almost 90% idea of this code. </p>
  
  <pre><code>var database = [{
      username: "Robin",
      password: "abc"
    },
  
    {
      username: "Alex",
      password: "123"
    },
  
    {
      username: "John",
      password: "2222"
    }
  
  ];
  
  var newsFeed = [{
      username: "Ron",
      timeline: "Well, I like facebook"
    },
  
    {
      username: "Alex",
      timeline: "Hello my friends"
    }
  
  ];
  
  usernamePrompt = prompt("What is your username?");
  passwordPromt = prompt("Enter your password now");
  
  function isUserValid(username, password) {
  
    for (var i = 0; i &lt; database.length; i++) {
      if (database[i].username === username &amp;&amp;
        database[i].password === password) {
        return true;
      }
    }
  
    return false;
  }
  
  // prompt input is firstly taken in this SignIn fuction.
  //but it seems like isUserValid firstly takes input from popmt.
  //I am so confused with the connection between these functions.
  function SignIn(user, pass) {
  
    if (isUserValid(user, pass)) {
      console.log(newsFeed);
    } else {
      alert("Wrong password, Please try again later");
    }
  
  }
  
  SignIn(usernamePrompt, passwordPromt);
  </code></pre>
  
  <p>The code is working 100% correct. Problem is the logic is not so much clear in mind  to understand.</p>