What I want to happen when someone doesn't log in properly
<p>I have a bootstrap/jquery/javascript app that allows the person to log in then they are taken to a table of contents page where they can click a link in order to play a video.
I have code on the table of contents page that gives them a personalized message.</p>

<pre><code>&lt;script type="text/javascript" language="javascript"&gt;
        function WelcomeMsg() {
            // Retrieve the users name.
          var name = localStorage.getItem('name');

          if (name != "undefined" &amp;&amp; name != "null") {
            document.getElementById('welcomeMessage').innerHTML = "Welcome " + name + " !" + "&amp;nbsp";
          } else
            document.getElementById('welcomeMessage').innerHTML = "Hello!";
          }
    &lt;/script&gt;
</code></pre>

<p>The code works well when someone logs in properly but if someone doesn't log in and skips directly to the tableOfContents.html page then I want the message to say simply "Hello." Unfortunately right now in that situation it says "Welcome null." Can someone tell me what I'm doing wrong? Thank you.</p>