Syntax Errors after running code in "yourplayground.js"

What is this error message SyntaxError: Unexpected token 'else' (at yourPlayground.js:36:1). I copied code exactly as the tutorial showed me. Although, I am getting this error message when the video guy doesn’t.

JavaScript Tutorial for Beginners - Full Course in 12 Hours (2022) - YouTube Watch 38:30 into the video.

The following is code that I am trying to run. Why do I get syntax error after hitting the run button?

let weather = 'sunny'

if (weather == 'rain') {
console.log('grab your umbrella')
console.log('wear your sunglasses')

You did not close the if statement in your code, so when it saw the else block, it threw an error. Try closing the if before you open the else.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.