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>