2021-01-07 HTML 입력받은 수 만큼 별 찍기

쪼레비·2021년 3월 30일
0
<!DOCTYPE html>
<html>
<head>
<meta charset="EUC-KR">
<title>Insert title here</title>

<script>
	function InputPrintStar(n) {
		for (var i = n; i >= 1; i--) {
			for (var o = i; o >= 1; o--) {
				document.write("*");
			}
			document.write("<br>");
		}
	}
</script>

</head>
<body>
	<script>
		//var choiceReplay;

		while (true) {
			var inputNum = parseInt(prompt("정수를 입력하세요 : ")); // 정수로 입력 받기
			InputPrintStar(inputNum); // 함수 호출

			var choiceReplay = prompt("계속 하시겠습니까? (Y / N)");
			if (choiceReplay == "Y" || choiceReplay == "y") {
				continue;
			} 
			else if (choiceReplay == "N" || choiceReplay == "n") {
				break;
			}
		}
	</script>
</body>
</html>
profile
잠팅이

0개의 댓글