web第五天和第六天作业

1.99乘法表

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Multiplication Table</title>
    <style>
        table {
            border-collapse: collapse;
        }

        td {
            border: 1px solid black;
            padding: 5px;
            text-align: center;
        }
    </style>
</head>
<body>
    <table>
            <script>
                for (let i = 1; i <= 9; i++) {
                    document.write("<tr>");
                    for (let j = 1; j <= i; j++) {
                        document.write(`<td>${j} * ${i} = ${i * j}</td>`);
                    }
                    document.write("</tr>");
                }
            </script>
    </table>
</body>
</html>

 2、封装函数,完成用户输入秒数,将转换完毕的时分秒打印出来


<!DOCTYPE html>
<html lang="en">
 
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <style>
        div{
            width: 100px;
            height: 100px;
            background-color: black;
            color: white;
            text-align: center;
            line-height: 100px;
        }
    </style>
</head>
 
<body>
    <script>
        let second = +prompt('请你输入一个秒数')
        function getDate(date) {
 
            let h = parseInt(date / 60 / 60 % 24)
            let m = parseInt(date / 60 % 60)
            let s = parseInt(date % 60)
            h = h < 10 ? '0' + h : h
            m = m < 10 ? '0' + m : m
            s = s < 10 ? '0' + s : s
            return `${h}:${m}:${s}`
        }
        let val = getDate(second)
        document.write(`<div>${val}</div>`)
    </script>
</body>
 
</html>
 

3.

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        let students = [               
                { name: '小明', age: 18, gender: '男', hometown: '河北省' },
                { name: '小红', age: 19, gender: '女', hometown: '河南省' },
                { name: '小刚', age: 17, gender: '男', hometown: '山西省' },
                { name: '小丽', age: 18, gender: '女', hometown: '山东省' }
            ]
        for(let k in students){
            console.log(students[k])
            for(let j in students[k]){
                console.log(j)
                console.log(students[k][j])
            }
        }
    </script>
</body>
</html>

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值