<!DOCTYPE html>
<html>
<head>
<title></title>
<style type="text/css">
tr{
text-align: center;
background-color: red;
}
td{
padding: 50px;
border: 1px black;
}
table{
border: 5px solid green;
}
</style>
</head>
<body>
<table >
<script type="text/javascript">
var num = prompt("Introduce el numero: ")*1;
if (isNaN(num)==false && num % 2 != 0) {
for(var i=1; i<=num;i+=2){
document.write('<tr>');
for(var x = i; x>=1 ;x--){
document.write('<td>');
document.write('</td>');
}
document.write('</tr>');
}
}else{
document.write("Numero incorrecto!")
}
// for (var i = num; i > 0; i-=2) {
</script>
</table>
</body>
</html>
In fact, what I'm trying to do is a pyramid with odd numbers. Where the entry would be odd numbers and this is drawing pyramid. What I want to do is center all the TDs. In such a way that a pyramid remains. Thanks ... Although I doubt that the exercise has it well done ...