How to do exercises

whats wrong with this code, console says uncaught syntax error/unexpected identifier.

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

<head>
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
  <title> Detta är en hemsida </title>
</head>

<body>
  <h1>this is the title</h1>

<script>

for (var i = 1; i <= 100 i++) {
console.log(i);
}


  </script>
  </body>
  </html>

You have an extra html tag on the top. That’s the reason you see a syntax error.

thanks for replying!
current code, followed along with Ivan, but still get a syntax error?

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


<head>
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
  <title> Detta är en hemsida </title>
</head>

<body>


<script>

var num_rows = 7;
for(var row = 0; row < num_rows; row++) {
  console.log(row number + row);
}
   </script>
  </body>
  </html>
´´´

You are using the wrong variable here. row number is not defined. I guess you wanted to use num_rows.

Hope this helps.

1 Like