Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 1 of 1
  1. #1
    New Coder
    Join Date
    Sep 2010
    Posts
    46
    Thanks
    1
    Thanked 1 Time in 1 Post

    Learning how arrays work

    I would really like to learn how arrays work. Up till now I have nothing but frustration. This program is designed to produce a result: sumR = 20 after all the loops. The output is redundant both alert and textbox with button (not defined here but functional with a <form name="myform">).

    Code:
         function getarray(){
               var a = [3,2,2,3,4,1];
    	   var b = [1,2,2,1,1,2];
    	   var sumR = 0;
    	   for (k = 0; k <= 5; k++){
    	        var sumR = sumR + (a[k] * b[k]);
    	    }//Next k
    	    window.document.myform.sum1.value = sumR;
    	    return sumR;
    	}
    	alert(getarray());
    Last edited by Philosophaie; 06-09-2012 at 03:25 AM.


 

Posting Permissions

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