개념
<script>
/*
[기억과 개수2]
- 랜덤 숫자 4개를 저장한 후,
- 가장 마지막 짝수를 출력하시오.
*/
/*
[출력예시]
9 4 6 9
6
*/
let r = Math.floor(Math.random() * 10) + 1;
let r2 = Math.floor(Math.random() * 10) + 1;
let r3 = Math.floor(Math.random() * 10) + 1;
let r4 = Math.floor(Math.random() * 10) + 1;
document.write(r, " ", r2, " ", r3, " ", r4, "<br>");
let a = 0;
if(r % 2 == 0) {
a = r;
}
if(r2 % 2 == 0) {
a = r2;
}
if(r3 % 2 == 0) {
a = r3;
}
if(r4 % 2 == 0) {
a = r4;
}
document.write(a);
</script>
HTML
복사