0

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>

1 Answers1

4

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
Community
  • 1
  • 1
brandonscript
  • 68,675
  • 32
  • 163
  • 220
  • Thought I'd add that using a linter will help you find compilation errors in your javascript. Just paste your code and it will pick through and point out simple errors. Really helps when you get to have a lot of code to search through and console isn't being helpful. The one I like to use is: http://www.javascriptlint.com/online_lint.php – Don Dec 27 '13 at 19:37
  • Thank you. can you please explain this to me create:function(e,ui){ console.log(e); I know about functions in javscript but i am not sure what this is doing. – Stacky Stack Dec 28 '13 at 02:53
  • Not really sure what you're asking? But if you've got a different question best to look for the answer on SO or ask a new one. – brandonscript Dec 28 '13 at 03:39