lundi 30 novembre 2015

Why dont number ,square and cube show when I run the code?

Im studying javascript with a book and there is this exercise: Calculate the squares and the cubes of the numbers from 0 to 10 and display values in an html table. They are supposed to display like this : Table

My code is this :

<head>

<script type="text/javascript">
<!--
var square;
var cube;
document.write("<table border='0'>");
for (var number = 0; number <=10; number +=1){
    square = number*number;
    cube = number*number*number;    
    document.write("<tr>");
    document.write("<td>");
    document.writeln(number);
    document.write("</td>");
    document.write("<td>");
    document.writeln(square);
    document.write("</td>");
    document.write("<td>");
    document.writeln(cube);
    document.write("</td>");
    document.write("</tr>");
}   
document.write("</table>");         
// -->
</script>
</head>

Problem is,when I run this I dont get the title which says Number Square Cube

I only get the numerical results...where is my mistake?




Aucun commentaire:

Enregistrer un commentaire