www.webdeveloper.com
Results 1 to 6 of 6

Thread: javascript return values

Hybrid View

  1. #1
    Join Date
    Nov 2013
    Location
    Matara
    Posts
    9

    javascript return values

    <html>
    <head>
    <script language="javascript" type="text/javascript">

    function test(name,subject1,subject2){
    total=subject1+subject2;
    avg=total/2;
    a= +name+"your total is"+total+"your average is"+avg+
    return (a);
    }

    document.write(test("tom"70,60));
    document.write(test("kate"78,60));

    </script>
    </head>
    </html>



    there are some place is wrong.I can't fix it.plz help me.

  2. #2
    Join Date
    May 2006
    Location
    Somewhere behind your screen
    Posts
    1,635
    Code:
    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="UTF-8" />
    <title>title</title>
    <script type="text/javascript">
    function test(name,subject1,subject2){
    var total=subject1+subject2,
    avg=total/2,
    a=name+" your total is "+total+" your average is "+avg;
    return(a);
    }
    document.write(test("tom",70,60));
    document.write('<br />');
    document.write(test("kate",78,60));
    </script>
    </head>
    <body></body>
    </html>
    xxx: Guess Buddhist riddle: "What is the sound of one hand clapping?"
    yyy: facepalm

  3. #3
    Join Date
    Nov 2013
    Location
    Matara
    Posts
    9
    thanks a lot

  4. #4
    Join Date
    May 2006
    Location
    Somewhere behind your screen
    Posts
    1,635
    anytime
    xxx: Guess Buddhist riddle: "What is the sound of one hand clapping?"
    yyy: facepalm

  5. #5
    Join Date
    Nov 2013
    Posts
    4
    Try this.

    <html>
    <head>
    <script language="javascript" type="text/javascript">

    function test(name,subject1,subject2){
    total=subject1+subject2;
    avg=total/2;
    a= name+"your total is"+total+"your average is"+avg;
    return a;
    }

    document.write(test("tom",70,60));
    document.write(test("kate",78,60));

    </script>
    </head>
    </html>

  6. #6
    Join Date
    Nov 2013
    Location
    Matara
    Posts
    9
    thanks a lot

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