두 수 입력하고 합, 차 구하기

조수경·2021년 11월 18일
0

HTML

목록 보기
51/96
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<link rel = "stylesheet" href = "../css/mystyle.css" type="text/css">

<script>
function proc1(){
	//입력
	su1 = parseInt(prompt("수1입력"));
	su2 = parseInt(prompt("수2입력"));
	
	add(su1, su2);
	document.getElementById('result1').innerHTML = "합=" + sum + "<br>";
	
	a=sub(su1, su2);
    //sub함수내에서 실행된 결과를 res로 전달 받는다
	document.getElementById('result1').innerHTML += "차=" + a;
}

function add(a, b){
	 sum = a + b;/*var을 빼야 결과가 나옴*/
	
}

function sub(a,b){
	var sub = a - b;
	return sub;
	
}
</script>
</head>
<body>
<div class = "box">
   <br>
  <button type = "button" onclick="proc1()">확인</button>
  <div id = "result1"></div>
</div>
</body>
</html>
profile
신입 개발자 입니다!!!

0개의 댓글