---
# System prepended metadata

title: JavaScript 99乘法表
tags: [JavaScript]

---

# JavaScript 99乘法表
###### tags: `JavaScript`
```
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        table{
    border-collapse:collapse;
    border:px solid rgba(55, 115, 184);
}
td{
    border:3px solid rgb(43, 169, 201);
}
    </style>
</head>
<body>
    <script>
        document.write(`<table width="450">`);
        document.write(`<tr>`);
        for(let i=2;i<10;i++){
           let to='';
            for(let j=1;j<10;j++){
                    to+=`${i}*${j}=${i*j}<br>`
            }
            document.write(`<td bgcolor="#D4FFFF"><font color="#FF0000">${to}</font></td>`);
        }
        document.write(`</tr></table>`)
    </script>
</body>
</html>
```

## 會被老師打的版本(?
```
<!DOCTYPE html>
<html lang="UTF-8">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>homework1</title>
    <style>
        table{
            border-collapse:collapse;
            border:px solid rgb(53, 107, 170);
        }

        td{
            border:3px solid rgb(41, 165, 196);
        }
    </style>
</head>
<script>
    function multiTable(){
        document.write(`<body><table width="450"><tr>`);
        columnsAdd(math = '', i = 2, j = 1);
        document.write(`</tr></table></body>`);
    }

    function columnsAdd(math, i, j){
        if(i == 10)
            return;

        if(j == 10){
            document.write(`<td bgcolor="#D4FFFF"><font color="#FF0000">${math}</font></td>`);
            return columnsAdd(math = '', i + 1, j = 1);
        }
        
        columnsAdd(math += `${i}*${j}=${i*j}<br>`, i, j + 1);
    }

    multiTable();
</script>
</html>
```