Help needed!

Hi guys, can some one tell me why this code it’s giving me an error?

let season = ‘summer’;

if (season === ‘spring’) {
console.log(‘It’s spring! The trees are budding!’);
else if (season === ‘winter’) {
console.log(‘It’s winter! Everything is covered in snow.’);
}
} else {
console.log(‘Invalid season.’);
}

Shouldn’t this run the ‘Invalid season’ string?

2 Likes

you forgot to close if

2 Likes

There apears to be a bracket to many.

3 Likes

Thanks birra, it worded! :wink:

2 Likes

@lolfail is correct aswell the if statement needs a closing bracket aswell.

let season = ‘summer’;

if (season === ‘spring’) {
    console.log(‘It’s spring! The trees are budding!’);
}
else if (season === ‘winter’) {
    console.log(‘It’s winter! Everything is covered in snow.’);
} else {
    console.log(‘Invalid season.’);
}

this should work

3 Likes

Thanks lolfail, yeah I forgot to up a bracket before the first else if and I also had one to many.

2 Likes