I need to create a display that will create tables of multiplications for 2, 3, 4, 5, 6, 7, 8, and 9. using 2 for loops.

2X1=1

2x2=4

2x3=6

need it for each variable.

Printable View

- 03-06-2011, 06:46 PMdakid2need help with multiplication
I need to create a display that will create tables of multiplications for 2, 3, 4, 5, 6, 7, 8, and 9. using 2 for loops.

2X1=1

2x2=4

2x3=6

need it for each variable. - 03-06-2011, 06:56 PMJosAH
- 03-06-2011, 07:19 PMdakid2
here is my code so far

var y = 1;

var x = 5;

for (y=1; y<11; y = y + 1){

sum = y * x;

document.write("<li>")

document.write ( y + " x " + x + " = " + sum + "<br>");

} - 03-06-2011, 07:22 PMJosAH
- 03-06-2011, 07:40 PMdakid2
I'm having trouble with writing the loop.

Thanks for your help. I will post my question in a javascript forum. - 03-06-2011, 08:05 PMJosAH
- 03-06-2011, 09:42 PMdakid2
Jos,

Thanks that worked. :) - 03-08-2011, 03:00 AMdakid2
Can you help me with this? I know its not javascript. I'm trying to write this code.

function sumThese() {

var sumEven=0, sum5=0;

for(i=0; i<100; i++) {

sumEven = (i % 2 == 0) ? parseInt(sumEven+i) : sumEven ; // if value of i modulus 2 is 0, gets all even numbers

sum5 = (i % 5 == 0) ? parseInt(sum5+i) : sum5 ; // if value of i modulus 5 is 0, gets all multiples of 5

}

alert("sumEven = " + sumEven + ", and sum5 = " + sum5);

} - 03-08-2011, 03:05 AMsunde887
Please make another thread, don't hijack old solved posts. When/if you make a new thread, please be sure to actually provide a concrete, detailed question.

- 03-08-2011, 04:37 AMDarrylBurke
Actually, it's not a hijack. It's the same OP back with another JavaScript question.

@dakid2: Please find a JavaScript forum, this isn't one.

db - 03-08-2011, 04:41 AMsunde887