Last active
July 2, 2019 08:37
-
-
Save Kkan9ma/5cccf1289afab6a64b712185975a629f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<meta http-equiv="X-UA-Compatible" content="ie=edge"> | |
</head> | |
<body> | |
<script> | |
var n = 1; // 조건식에 쓰일 값 | |
var sum = 0; // 합계 | |
var count = -1;// 더한 횟수: 0이 한 번 더 더해지는 것을 빼주기 위해 -1로 설정. | |
while(n != 0){ | |
n = Number(prompt("숫자를 입력하세요(0을 입력하면 종료)")); | |
sum += n; | |
count++; | |
} | |
document.write("입력한 수의 갯수는 " + count + "개고, 합은 " + sum + "입니다."); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment