SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    Non-Member
    Join Date
    Jan 2008
    Location
    N43 44.4824', W079 13.9408
    Posts
    2,220
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Basic Learning - Why won't this print ?

    Code JavaScript:
     var cookies="cookies_and_cookies_cookies_cookies"
     var blah_blah_blah="whatever"
    function reallycool(cookies){
      document.write("whatever you like to do" +cookies);
      }

    Could someone tell me what this won't print when I have named the function and have a variable in the parameter and I can't see any errors in the syntax ?

  2. #2
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,678
    Mentioned
    99 Post(s)
    Tagged
    4 Thread(s)
    When you declare a function, the code inside that function doesn't actually run until you call it, and provide it with its parameters.

    For example, you could follow the above code with:

    Code javascript:
    reallycool(blah_blah_blah);

    or


    Code javascript:
    reallycool(', I do too');
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  3. #3
    Non-Member
    Join Date
    Jan 2008
    Location
    N43 44.4824', W079 13.9408
    Posts
    2,220
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I can't get this to work, I'm going to have to read up a little more. Thanx


Bookmarks

Posting Permissions

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