title: Return variable value of JavaScript function
body: <p>So guys, I have a JavaScript function that should return an Array with values. Here is the function:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>let finalInput;
  let input;
  function getCorrectInput (input, finalInput) {
    input = prompt("Type the client type followed by" +
    "semicollon and the dates separated by comma"+
    "(Following the example: Reward: 31Dez2019(weekday), 01Jan2020(weekday)):");
  
    while (input === undefined || input === null || input === '') {
      input = prompt("Type the client type followed by" +
      "semicollon and the dates separated by comma"+
      "(Following the example: Reward: 31Dez2019(weekday), 01Jan2020(weekday)):");
    } 
  
    if (input) 
      return 
  
      finalInput = input.split(',');
    
    return finalInput
  }
  
  getCorrectInput()</code></pre>
  </div>
  </div>
  </p>
  
  <p>Basically, the function verifies if the field contains something (if the user typed) and returns the content inside the input. So the output of the function should be something like that:</p>
  
  <pre><code>finalInput = ["Reward", "date1", "date2"]
  </code></pre>
  
  <p>I need to access the finalInput at position [0], and pass it to a variable, like that:</p>
  
  <pre><code>const clientType = finalInput[0]
  </code></pre>
  
  <p>But when I try to access the finalInput, it returns an error saying that it cannot read property 0 of undefined. So it means that the code is not returning the array with the values. </p>
  
  <p>What am I doing wrong? </p>