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

so are booleans and if-blocks initrinsically linked within JS? I

I am confused when he says that you can remove the strict equality sign and the if-block still understands

1 Answer

Hi Paul,

if statements work like this:

if (true) { /* do this */}

Sometimes we can make them more complex than they are, but if you want the code in an if block to run, then the expression between the parens, next to the if keyword, just needs to evaluate as true.

Let's say you have the following code:

app.js
const theSkyIsBlue = true

If you wanted to have the message "This is a true statement" print if theSkyIsBlue is true, then you might write something like this...

app.js
if (theSkyIsBlue === true) {
    console.log("This is a true statement.");
}

The above code would work just fine, but remember the format for a if block to run is if true do this, and theSkyIsBlue is already true. So you could simply write:

app.js
if (theSkyIsBlue) {
    console.log("This is a true statement.");
}

There isn't a video linked to this post, but I imagine that's the point the instructor was trying to get across.

that is very helpful. thank you for the response