Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript JavaScript Basics (Retired) Making Decisions with Conditional Statements The Conditional Challenge

Marcell Ciszek
Marcell Ciszek
7,255 Points

Why does this code always print correct even if i don't fill in the prompt?

let quiz2 = prompt('name at least one of my brothers name') if (quiz2 === 'filip' || 'hector'){ alert('correct') } else { alert('wrong!'); }

Aurelian Spodarec
Aurelian Spodarec
10,801 Points

This is a much better formating.

var = 1;

You use it without the /

/```javascript

/```

1 Answer

Magnus Hållberg
Magnus Hållberg
17,232 Points

It's because the if statement is missing what to test "hector" against. It needs to be more specific, like this.

if (quiz2 ===  'filip' || quiz2 ===  'hector')

Then it should work.

Marcell Ciszek
Marcell Ciszek
7,255 Points

Thank you Magnus, and tack så mycket för hjälpen!