Day 10 "random"

Hector·2023년 3월 25일
0

Vanilla JavaScript

목록 보기
10/14
<!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>
    <script src="./script.js"></script>
</head>
<body>
    <h1>Today dish wash</h1>
    <button onclick="random()">뿅!!</button>
    <h1 id="answer"></h1>
</body>
</html>
<script>
function random(){
    let num = parseInt(Math.random(10)*10);
    let answer = document.getElementById('answer');
    answer.innerText='';
    
    if(num%2===0){
        answer.innerText='안성민!'
    }else{
        answer.innerText='박누리!'
    }
}
</script>
profile
I`m Studying Bankend

0개의 댓글