Why is my JavaScript function giving the error of undefined?

Here is my javascript code. I am printing these two values in the console. But instead of getting two values, I got the print of “In global” on the console and the 2nd one is undefined.


    <script>
        var x ="In global";
        console.log(x);
        var a = function () {
            var x = "Hi I am Noor";
            console.log(message);
             }    
    </script>