JavaScript that calculates the squares and cubes of the numbers from 0 to 10

				
					<!DOCTYPE HTML> 
<html> 
<head> 
<style>
     table,tr, td
     { 
         border: solid black; width: 33%; text-align: center; border-collapse: collapse; background-color:lightblue; 
     } 
     table 
     {
     margin: auto;
     } 
     </style> 
     <script> 
     document.write( "<table><tr><thcolspan='3'> NUMBERS FROM 0 TO 10 WITH THEIR SQUARES AND CUBES </th></tr>" ); 
     document.write( "<tr><td>Number</td><td>Square</td><td>Cube</td></tr>" );
     for(var n=0; n<=10; n++) 
     {
         document.write( "<tr><td>" + n + "</td><td>" + n*n + "</td><td>" + n*n*n + "</td></tr>" ) ; 
     } 
     document.write( "</table>" ) ; 
     </script> 
     </head> 
     </html>
				
			

Leave a Reply