JavaScript help? -
05-29-2003, 01:19 AM
hey, anyone out there can they help me with some JavaScript @ skool my class is learning JavaScript and here is the prob we have to change this program below we have to write a program line to make it add 5 to the number. (NOTE: ALL THE JAVASCRIPT IS IN ITALIC)
<script language = 'javascript'>
var theNumber;
var theSquare;
theNumber = window.prompt("Enter a number ");
theSquare = theNumber * theNumber;
document.write("Hello. The square of " + theNumber + " is " + theSquare + "
");
document.write("Welcome to my Web page.");
</script>
and this one plz
now with this one we have to make it the program which has the computer write one hundred lines saying 'This is getting monotonous'
here is the source
<script language = 'javascript'>
var theNumber;
var theSquare;
var count;
theNumber = 20;
for (count = 0; count < 10; count++)
{
theSquare = theNumber * theNumber;
document.write("Hello. The square of " + theNumber + " is " + theSquare +"
");
theNumber++;
} //end of for loop
</script>
and also if you can the first one i have to make it print out 5 square numbers by the putting the document.write into a for loop
last one soz for this being so long we have to write a program that will allow you to calculate the squares of negative and which will continue until your enter a number greater than 0
source code
<script language = 'javascript'>
var theNumber;
var theSquare;
do
{
theNumber = window.prompt("Enter a number ");
theSquare = theNumber * theNumber;
document.write("The square of " + theNumber + " is " + theSquare + "
");
}while (theNumber > 0); //end of for loop
</script>
any help would be greatly appreciated biggrin: angel:
|