www.webdeveloper.com
Results 1 to 2 of 2

Thread: Javascript LOOPS and ARRAYS situation, help

Hybrid View

  1. #1
    Join Date
    Nov 2010
    Posts
    21

    Javascript LOOPS and ARRAYS situation, help

    How does my array look so far?

    thanks

    I think so
    what i was supposed to do was
    insert a script element that contains the function
    amountTotal()

    then add commands to the function
    such as
    1 declare variable named total, set intial value to 0
    2 create a FOR LOOP that loops all values in amount array.
    add current value of array item to value of total variable
    3 when completed return value of total variable

    This is what I came up with
    tell me if this makes sense

    Thanks
    title>The Lighthouse</title>
    <link href="lhouse.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="list.js"></script>

    <script type="text/javascript">

    function amountTotal() {
    totalAmount=0;
    for(var i=0; i<amountTotal.length; i++){
    total+=amount(i);

    {
    return total;
    }
    </script>
    </head>
    Does this seem right or is my format all wrong?
    if so what should i have instead?
    thanks

  2. #2
    Join Date
    Mar 2007
    Location
    U.K.
    Posts
    1,127
    Quote Originally Posted by worldtraveller View Post

    Does this seem right or is my format all wrong?
    if so what should i have instead?
    thanks
    Try using your browser's error console, preferably Firefox.
    Where used, return should be executed unconditionally and always as the last statement in the function.

    That's my signature, it's not part of the damn post!

Thread Information

Users Browsing this Thread

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

Tags for this Thread

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