[英]why i am not getting output in this code?
<!DOCTYPE html>
<html>
<head>
<title> javascript </title>
</head>
<body>
<h2>JavaScript switch</h2>
<p id="demo"></p>
<script>
let x = prompt('enter no');
switch (x) {
case 0:
text = "off";
break;
case 1:
text = "On";
break;
default:
text = "No value found";
}
document.getElementById("demo").innerHTML=text;
</script>
</body>
</html>
in the above code i want user to enter the input and then i want to display output but every time i try to do this the the only defaut=lt output comes output, why?在上面的代码中,我希望用户输入输入,然后我想显示 output 但每次我尝试这样做时,唯一的默认值 = lt output 出现 Z78E6221F6393D1356681DB398F14CEDZ,为什么?
Use Number() to convert to a numerical value使用 Number() 转换为数值
let x = Number(prompt('enter no'));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.