title: Calling a function inside another function
body: <p>I am trying to call the getWinner function inside the playFiveTimes function and every time I try to test my code it gives me an error that says: "playerMove undefined" or if I try and type "rock" it says that is undefined as well. I am completely lost at this point. Any help would be appreciated.</p>
  
  <pre><code>'use strict';
  
  function getInput() {
    console.log("Please choose either 'rock', 'paper', or 'scissors'.")
    return prompt();
  }
  
  function randomPlay() {
    var randomNumber = Math.random();
    if (randomNumber &lt; 0.33) {
      return "rock";
    } else if (randomNumber &lt; 0.66) {
      return "paper";
    } else {
      return "scissors";
    }
  }
  
  function getPlayerMove(move) {
    if (!move) {
      move = getInput();
    }
    return move;
  }
  
  function getComputerMove(move) {
    if (!move) {
      move = getInput();
    }
    return move;
  }
  
  function getWinner(playerMove, computerMove) {
    var winner;
    if (playerMove === computerMove) {
      return ("It's a tie!");
    } else if (playerMove === "rock") {
      if (computerMove === "paper") {
        return "paper wins";
      } else {
        return "rock wins";
      }
    } else if (playerMove === "paper") {
      if (computerMove === "rock") {
        return "paper wins";
      } else {
        return "scissors wins";
      }
    } else if (playerMove === "scissors") {
      if (computerMove === "paper") {
        return "scissors wins";
      } else {
        return "rock wins";
      }
    }
    return winner;
  }
  
  function playToFive() {
    console.log("Let's play Rock, Paper, Scissors");
    var playerWins = 0;
    var computerWins = 0;
    // Write code that plays 'Rock, Paper, Scissors' until either the player or the computer has won five times.
    while ((playerWins &lt; 5) &amp;&amp; (computerWins &lt; 5)) {
      getWinner();
      if (playerWins) {
        playerWins += 1
      } else {
        computerWins += 1
      }
    }
  
    console.log("Player chose " + playerMove + " while computer chose " + computerMove);
    console.log("The score is currently " + playerWins + " to " + computerWins + "\n");
    return [playerWins, computerWins];
  }
  console.log(playToFive());
  </code></pre>