Skip to content

Instantly share code, notes, and snippets.

@Kkan9ma
Last active July 2, 2019 08:37
Show Gist options
  • Save Kkan9ma/5cccf1289afab6a64b712185975a629f to your computer and use it in GitHub Desktop.
Save Kkan9ma/5cccf1289afab6a64b712185975a629f to your computer and use it in GitHub Desktop.
<!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