JAVA_EE/JavaScript
[JavaScript] 조건에 따른 값 도출
luvforjunk
2021. 9. 10. 20:12
728x90
반응형
[21.09.10] exam11
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<script type="text/javascript">
function f(x, y){
var z = x + y;
if(z < 10) {
return; //함수를 벗어나라
}
return z;
}
let a = f(2, 1);
let b = f(5, 7);
let c = f(10, 5);
document.write("<h3>" + a + "</h3>"); // undefined - 선언은 되어 있지만 값이 없는 상태
document.write("<h3>" + b + "</h3>");
document.write("<h3>" + c + "</h3>");
</script>
</head>
<body>
</body>
</html>
728x90
반응형