JavaScript_2강_5_삼항 연산자

열라뽕따히·2024년 3월 7일

JavaScript

목록 보기
9/37

삼항 연산자

형식) (조건식) ? 참인 경우 실행문 : 거짓인 경우 실행문


=============================코드=============================

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<script type="text/javascript">

		// 삼항 연산자	
		let num = 27;
		
		let result = (num > 20) ? "참" : false;
		document.write(`result >>> ${result} <br/>`);

</script>
</head>
<body>

</body>
</html>

=============================실행=============================

0개의 댓글