Home  >  Q&A  >  body text

The following statements are not displayed

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>shiyan</title>
</head>
<body>
  <script>
     var box=1;
     switch(box){
          case 1:document.write("数字1")
          baeak;  
          case 2:document.write("数字2")
          baeak;   
          case 3:document.write("数字3")
          baeak;  
          default:document.write("以上数值都不匹配")
      }
          var str="how do you do";
          var v1=str.indexOf("do");
          document.write(v1+"<br>");//返回do字符串起始位置
          var v2=str.lastIndexOf("do");
          document.write(v2+"<br>");//返回do字符串 最后一个字符串的开始位置
  </script>
</body>
</html>

老师您好, 前面是一个switch语句,在浏览器打印出了数字1,但是后面测试字符串
起始位置的语句没有执行打印, 把switch语句注释后,可以正常执行打印出字符串
的位置,  这个是什么原因, 请指教!  谢谢!!!


李涛李涛2097 days ago1081

reply all(2)I'll reply

  • 刘宁

    刘宁2019-01-23 09:32:47

    break;Your switch is written incorrectly

    reply
    0
  • 李涛

    Thanks!

    李涛 · 2019-01-23 16:52:51
  • Cancelreply