Clarification of passing params in Javascript
<p>I am currently learning javascript and am a litte confused with passing parameters through functions, I was hoping someone could give a clearer explanation</p>

<p>I have the following simple code</p>

<pre><code>     //generate random number
     var number = Math.round(Math.random()*10 + 1);

     //Ask user for name
     var playerName = prompt("What is your name?");

     //Prompt for intro
    var weclome =   alert("Hello " + playerName + " Welcome to Guess the Number");
    console.log(number);

    var playerGuess = prompt("What is your guess ");

    if (playerGuess !== null) guess(playerGuess);

   function guess(pGuess){ 
    if(pGuess == number) {
     alert("Congratulations you have guessed correctly");
    } else {
     alert("Unlucky, please try again");
  }  
}
</code></pre>

<p>As you can see its ust a simple guess the number game. From what i understand so far I have assigned the variable playerGuess as the result of the input from the prompt, which I pass through the guess function. What I dont understand is that i have called the param pGuess within the guess function. My understanding is that this should not work, but yet it does, how does pGuess know to get its value from playerGuess.</p>

<p>Am I looking at this in totally the wrong way, I would really like to understand this</p>

<p>Thanks</p>
