Solution 1 :

The error is in the first line of your code.

let(js = 'Amazing');

JavaScript will assume let to be a function, instead of a keyword, which is what you actually want it to be interpreted as.
Remove the parentheses enclosing what comes after let, and it will work.

let js = 'Amazing';

Syntax for let (MDN):

let name1 [= value1] [, name2 [= value2]] [, ..., nameN [= valueN];

Solution 2 :

Seems like you are setting your variable wrong. When setting variables you want to use the = operator without the ()

Old:
let(js = 'Amazing');

New:
let js = 'Amazing';

Solution 3 :

let js = 'Amazing';
if (js === 'Amazing') {
    alert('JavaScript is Fun!');
}

replace your script code with this.

Problem :

I am just a beginner, learning code from an online Bootcamp. The tutor gave us a prewritten code in which we just had to add a few lines using Visual Studio Code and open that file in Google Chrome But My browser is not showing the changes I have made in Code even though I have done exactly similarly as shown in the tutorial by the tutor. Please check the code and give me your insight. Thank You (do read the Note at the end of the code).

<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  <meta http-equiv="X-UA-Compatible" content="ie=edge" />
  <title>JavaScript Fundamentals – Part 1</title>
  <style>
    body {
      height: 100vh;
      display: flex;
      align-items: center;
      background: linear-gradient(to top left, #28b487, #7dd56f);
    }

    h1 {
      font-family: sans-serif;
      font-size: 50px;
      line-height: 1.3;
      width: 100%;
      padding: 30px;
      text-align: center;
      color: white;
    }
  </style>
</head>
<script>
  let(js = 'Amazing');
  if (js === 'Amazing') alert('JavaScript is Fun!');
</script>

<body>
  <h1>JavaScript Fundamentals – Part 1</h1>
</body>

</html>

NOTE:
(This code does not open in Chrome. chrome only shows “JavaScript Fundamentals – Part 1” instead of the pop up “JavaScript is Fun”)

Comments

Comment posted by mason

Did you check your browser’s debug console for errors? That’s the first place you should look if you have JavaScript code that’s not working as expected. Are you absolutely certain the code you’ve copied matches what the bootcamp is showing you?

Comment posted by Alan Omar

use

Comment posted by Rateb Habbab

When you define a variable in javascript don’t use ‘()’. Just:

Comment posted by Fraz Zahid

Thank You so much, I rechecked it at least 10 times still the parenthesis was overlooked by me.

Comment posted by Fraz Zahid

Thanks for the information 🙂

Comment posted by Fraz Zahid

Thank You. I will keep this in mind 🙂

Comment posted by Aziza Kasenova

you can use formatting to format your answer to look a bit more friendly 🙂

By