title: Uncaught ReferenceError: platform is not defined
body: <p>Yes so i recently picked up javascript as another language to learn. I was working on a friend's website and we need to keep logs of the platform OS so that we can rate our stats. </p>
  
  <p>I get the error Uncaught ReferenceError: platform is not defined at get_platform (eval at  (file:///C:/Users/*****/Desktop/Project/index.html:2:9), :1:191)</p>
  
  <p>Does anyone have any idea on how i could go about fixing this? Any help is greatly appreciated! </p>
  
  <p>This is my code. </p>
  
  <pre><code>function get_platform(os_name) {
  var os_str = os_name;
  var chk_win = os_str.substr(0, 3);
  if (chk_win == "Win")
      platform = "win";
  if (chk_win == "Lin")
      platform = "linux";
  if (chk_win == "X11")
      platform = "unix";
  return platform};
  function get_os() {
  var OSName = "Unknown";
  if (window.navigator.userAgent.indexOf("Windows NT 6.3") != -1)
      OSName = "Windows 8.1";
  if (window.navigator.userAgent.indexOf("Windows NT 6.2") != -1)
      OSName = "Windows 8";
  if (window.navigator.userAgent.indexOf("Windows NT 6.1") != -1)
      OSName = "Windows 7";
  if (window.navigator.userAgent.indexOf("Windows NT 6.0") != -1)
      OSName = "Windows Vista";
  if (window.navigator.userAgent.indexOf("Windows NT 5.1") != -1)
      OSName = "Windows XP";
  if (window.navigator.userAgent.indexOf("Windows NT 5.0") != -1)
      OSName = "Windows 2000";
  if (window.navigator.userAgent.indexOf("Mac") != -1)
      OSName = "Mac/iOS";
  if (window.navigator.userAgent.indexOf("X11") != -1)
      OSName = "UNIX";
  if (window.navigator.userAgent.indexOf("Linux") != -1)
      OSName = "Linux";
  return OSName};
  </code></pre>