title: let variable is not defined
body: <pre><code>function formatToStandardizedDate(from, to){
  
      const from_date = moment(from);
  
      if(to){
          let to_date = moment(to);
      }else{
          let to_date = null;
      }
  }
  
  console.log(formatToStandardizedDate("2017-04-19 00:00:00",null))
  </code></pre>
  
  <p>What's wrong with my code above? if <code>to</code> is null it at least assign a null to <code>to_date</code> but I got error of <code>to_date</code> of undefined error. Why?</p>