dcsimg
www.webdeveloper.com
Results 1 to 3 of 3

Thread: Why isn't this working?

Hybrid View

  1. #1
    Join Date
    Feb 2014
    Posts
    5

    Why isn't this working?

    (Html Script):

    <!DOCTYPE html>
    <html>
    <head>
    <title>Brandons Functions</title>
    </head>
    <body>
    <script type="text/javascript" src="prjs4_2.js"></script>
    <strong>This is some strong text.</strong></br>
    </body>
    <script>
    document.write(stringTwo);
    </script>
    </html>

    -----------------------------------

    (The Js Script, "prjs4_2.js")

    function twoStrings(a, b) {
    return a+' '+b;
    }
    function pointless(a){
    return a;
    }

    var stringOne = pointless(twoStrings('hi', 'there!'));
    document.write(stringOne);

    var stringtwo = twoStrings('Regular', 'text!');

    alert(stringTwo);

    ----------------------------------------

    Please help?

  2. #2
    Join Date
    Oct 2012
    Location
    Croatia
    Posts
    255
    It's a typo...

    Code:
    var stringTwo = twoStrings('Regular', 'text!');;

  3. #3
    Join Date
    Mar 2007
    Location
    localhost
    Posts
    2,725
    Typos...

    If you run a script in your browser and when the desired result does not appear to work, what you can do is start trouble shooting issues yourself by hitting the F12 key and clicking on console and ensuring that the ALL errors option is selected.

    That will tell you things like the variable is undefined or does not exist or an exception error occurred, indicating that you have a problem with a variable that you have called or function you called that does not exist.

    This is a great help to working out what is wrong with your script and will get you further faster than having to wait for someone to point out what is wrong. It will also likely score you brownie points for showing some initiative.
    STOP using $ prefix on JavaScript variable names...
    Please remember to wrap any code you have in forum tags:-

    [CODE]...[/CODE] [HTML]...[/HTML] [PHP]...[/PHP]

    If you can't think outside the box, you will be trapped forever with no escape...

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles