简体   繁体   中英

JavaScript being weird in Brackets code editor

I'm using JS in brackets, and I'm having some problems. First, the alert property doesn't work. Is this just because of brackets live preview? Second, it doesn't tell me when I've made errors )I entered in nonsensical commands, and there was no errors at all. Also, when I named a variable starting with a number, no error message! These are just problems I noticed in the last 5 minutes. Please help! Here's my code:

<html>
    <head>
    <script>
        document.write("Hello world");
        var someText = " years old";
        var years = 35;
        alert(years + sometext);
    </script>
</head>

<body>
</body>
</html>

You declare your variable as someText but then refer to it as sometext in your alert:

<html>
  <head>
    <script>
      document.write("Hello world");
      var someText = " years old";
      var years = 35;
      alert(years + someText); // <--
    </script>
  </head>
  <body></body>
</html>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM