Hello and welcome to our community! Is this your first visit?
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
    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">).

         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;
    Last edited by Philosophaie; 06-09-2012 at 04: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