Stacky Stack
Stacky Stack

Reputation: 1

javascript wont run on my browser

I am following an on-line tutorial on JavaScript. Currently the guy is teaching functions, when I copy what he is doing and have exactly the same text on my editor it does not work on chrome or any other browser.

I did some research and people were saying JavaScript is blocked, however I checked in chrome and its not. I went to settings, content settings and I can see that is says " Allow all sites to run JavaScript (recommended)".

I do not get an error, just a blank page. I am completely new to programming and this is putting me off the tutorial.

              <!DOCTYPE html>
                <html>
                <head
                <title>Functions</title>
                 </head>
                <body>
               <script type="text/javascript">



              var foo = doSomething(2);
              var bar = doSomething(3);
              function doSomething(paramOne){

          paramOne = paramOne + 3;
          paramOne = paramOne + 1;
          paramOne = ParamOne * 8 ;

           return paramOne;

               }

              alert(foo);
              alert(bar);


              </script>

              </body>
              </html>

Upvotes: 0

Views: 130

Answers (1)

brandonscript
brandonscript

Reputation: 72875

If you look in Chrome's console (right-click > Inspect Element, select the Console tab)

You'll see:

Uncaught ReferenceError: ParamOne is not defined

This is because you have a capital P on ParamOne in your third line.

Because Javascript (and most other programming languages) are case-sensitive, you'll need to make it lowercase:

paramOne = paramOne + 3;
paramOne = paramOne + 1;
paramOne = paramOne * 8;
        // ^ was a capital P

Upvotes: 4

Related Questions