SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Addict ebermed's Avatar
    Join Date
    Oct 2009
    Location
    North East Florida USA
    Posts
    20
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Simply Java Script

    I am using the Simply JavaScript book. In the exercise for Associative Arrays I have copied the script identically and it will not work in browser. Can someone see where I am in error. For some reason attachments icon is dead so here are the contents of my files.

    Many Thanks,

    Mike

    contests of simply.js

    var postcodes =[];
    postcodes["Armadale"] =3143;
    postcodes["North Melbourne"] =3221;
    postcodes["Camperdown") =2050;
    postcodes["Annandale"] =2038;
    alert(postcodes["Annandale"]);

    contents of default.html

    links removed

    <head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
    <title>Untitled 1</title>
    <script type="text/javascript" src="simply.js">
    </script>

    </head>

    <body>

    </body>

    </html>

  2. #2
    SitePoint Zealot atetlaw's Avatar
    Join Date
    Feb 2007
    Location
    Melbourne, Australia
    Posts
    171
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi ebermed,

    Here's your problem:

    postcodes["Camperdown") =2050;

    That ')' should be a ']'.


Tags for this Thread

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
  •