Quote:
Originally Posted by SakSquash
document.write I know, as well as document.writeln, but no clue about looping. There is some stuff in the book about it, but nothing that has to do with "squares and cubes." Trust me, i've looked all through the book.
|
That's all you need to know, then. squares and cubes are simple math. The square of a number is the number times itself, and the cube is the square times the number again.
So, let's say you have a variable:
var number = 0;
If you were to make a loop that executed ten times (check out for loops), and if you added one to the number each time, it'd be pretty simple to write out the squares and cubes.
(To do powers in javascript, by the way, use Math.pow(number,power)