[Js syntax] How to use ternary operators

Programming practice

There are 2 grades, 50 and 70. Use the ternary operator to judge, when the score is greater than 60, the output is passing, and when the score is less than 60, the output is failing.

<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>三元操作符</title>
</head>
<body>
    <script>
		//补充代码
		var a=50,b=70;
		console.log((a>=60)?"及格":"不及格");
		console.log((b>=60)?"及格":"不及格");
	</script>
</body>
</html>

result

 

Guess you like

Origin blog.csdn.net/qq_39799094/article/details/108986664