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 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,858 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
229,644 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
}