<!DOCTYPE html>
<html lang="ko">
<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>
<h1>BMI 테스트</h1>
<label for="">키 <input type="text" name="" id="height"></label>
<br><br>
<label for="">체중 <input type="text" name="" id="weight"></label>
<br><br>
<button>계산</button>
<hr>
<h1>BMI 수치 : <span id="bmi"></span></h1>
<script>
const 키 = document.querySelector("#height")
const 체중 = document.querySelector("#weight")
let 입력한키
let 입력한체중
let bmi
const bmi지정 = document.querySelector("#bmi")
const 버튼 = document.querySelector("button")
버튼.addEventListener("click", function() {
입력한키 = 키.value / 100
입력한체중 = 체중.value
bmi = 입력한체중 / (입력한키*입력한키)
bmi지정.innerHTML = bmi.toFixed(3)
})
</script>
</body>
</html>