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 trialCharles Harpke
33,986 PointsAdd a Boolean value to the condition in this conditional statement. Use a boolean value that will result in the message
Not quite understanding the question..... here is my code:
var Admin = true;
var Student = false;
if ( Admin = true) {
alert('This is true');
} else {
alert('This is false');
}
the error is receive is this:
Bummer! Did you add true
inside the parentheses of the conditional statement?
10 Answers
Andrew Shook
31,709 PointsCharles, you are using the assignment operator(i.e. setting a variable equal to) and not using a comparison operator ( == or ===) in your if statement. That is why the challenge won't pass. Technically, you don't need to use a comparison operator here, you could just put the variable that equals true and the if statement will pass.
Robert Mckay
11,089 PointsThis needs to be modified - to include the ability to put in a boolean value through a variable. Or the question needs to be changed so that the user knows that it is actually not looking for a variable to be set to a Boolean value.
Rickie Thornley
Full Stack JavaScript Techdegree Student 7,440 PointsI agree - This does not specify (in 2017) that the user need not create a value for this. Theres no need to be cryptic, real work places are not cryptic in what they are asking you to develop for purposes to avoid confusion to get the software they need.
Ken Alger
Treehouse TeacherCharles;
For this challenge think simplify when it comes to the task instructions and especially with the challenge error message, it is rather explicit in what you need to do.
Post back if you are still stuck.
Ken
Tyler Groskreutz
14,793 PointsI feel I've done everything correctly, but I am still getting the same error as Charles. Thoughts?
```var foo = true;
if (foo === true) { alert('This is true'); } else { alert('This is false'); }```
Nathan Josef
4,805 PointsThanks Charles. This was helpful
Mihai Tabla
6,493 Pointsthe correct answer to this was
if (true) { alert('This is true'); } else { alert('This is false'); }
Shaun Wong
14,489 PointsThanks, this worked.
Mihai Tabla
6,493 Pointsstil i haven't managed to pass this task.
my code:
var aGuess = false; if (aGuess===true) { alert('This is true'); } else { alert('This is false'); }
What do i do wrong ?
Andrew Shook
31,709 PointsChange the value of aGuess to true.
Jeff Ward
8,978 PointsFor everyones viewing pleasure:
if (true ) {
alert('This is true');
} else {
alert('This is false');
}
stephenallison
8,559 PointsThe question simply ask for the Boolean value that will result in a statement change. By placing "true" in the if statement satisfies the equation.
if ( true ) { alert('This is true'); } else { alert('This is false'); }
Charles Harpke
33,986 PointsAh...thank you...yes...I didn't use the comparison operator...just the Boolean and voila....
jonpaul uritis
6,669 PointsJeffs answer works :
if (true ) {
alert('This is true');
} else {
alert('This is false');
}
however ('true' == true) or any combination of a statement that evaluates to true doesn't. I tried 15 or so. Just letting everyone know
Midhun Chandran
9,414 PointsEnsure that you type in 'true' and not 'True'
Hence the correct statement is: if (true) { alert('This is true'); } else { alert('This is false'); }
Shuvam Roy
2,753 Pointsif (true ) {
alert('This is true');
} else {
alert('This is false');
}```
Ken Alger
Treehouse TeacherKen Alger
Treehouse Teacheredited for markup