Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

JavaScript JavaScript Basics (Retired) Making Decisions with Conditional Statements A Basic If Statement

how to show if a conditional statement that tests is true/false

I am learning conditional statements an in two challenges they ask you to show if something is True or if something equals a certain number. I cannot get my code to work please advise.

Jason Anders
Jason Anders
Treehouse Moderator 145,631 Points

You will need to show the code you have tried. This will enable us to best help you troubleshoot where the problem may be.

You can either re-post this question from the challenge as you have, but make sure you have typed in your code and have checked the "include code" box before submitting.

or

You can copy / paste your code here. If doing so, please refer to the Markdown Cheatsheet for proper formatting syntax to post code in the Community.

:dizzy:

1 Answer

Steven Parker
Steven Parker
218,694 Points

Here's a generic hint:

Without seeing your code I can just give you a generic hint. To test if something is true you only need to name it as the conditional expression. For example, if you have a boolean variable named maybeTrue:

if (maybeTrue) {
  // code here for when true
}

Then to test if something equals a certain number you'd use the equality operator which is two equal signs. For example to see if a variable named howMuch is equal to 12:

if (howMuch == 12) {
  // code here for when equal to 12
}