
函数
为什么需要函数
函数使用
函数传参
函数返回值
采取数组的形式返回多个值
作用域
匿名函数
综合案例
学到的知识点:
1.返回值可以通过返回数组实现返回多个值
2.parseInt强转
<!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>
</body>
<script>
let second= prompt('输入总的秒数')
function time(){
hour = second/3600
// console.log(parseInt(hour))
minute = (second%3600)/60
// console.log(parseInt(minute))
second1 = (second%3600)%60
// console.log(parseInt(second1))
return [parseInt(hour),parseInt(minute),parseInt(second1)]
}
time()
document.write(`
<p>${second}转换为${time()[0]}小时${time()[1]}分钟${time()[2]}秒</p>
`)
</script>
</html>