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 Making Decisions in Your Code with Conditional Statements Boolean Values

Hello, i have a question . is it common to have a second conditional statement? altought i m a beginner to JS. i never s

Hello, i have a question . is it common to have a second conditional statement? altought i m a beginner to JS. i never saw this. can anyone give me some info on this?

Steven Parker
Steven Parker
231,269 Points

It's not clear what you are asking about. Perhaps you could show the code, or give a time reference in the video where the "second conditional statement" can be seen.

3 Answers

your are right :) thanks for the replay:

Hello, i have a question . is it common to have a second conditional statement? altought i m a beginner to JS. i never saw this. can anyone give me some info on this? i saw it the first time during this video

let correctGuess = false; const number = 6 ; const guess =prompt("guess a number between 1-10");

if (+guess === number) {

correctGuess = true;

} if ( correctGuess=== true) { console.log('The condition is false.'); }

else { console.log(Sorry. the number was ${number}); }

Randy Assmann
Randy Assmann
3,585 Points

your right i had the same question. in the video the teachers uses two if statements. he could just use one if statement and use that to do two things at once like checking if the condition is true and imediatly print it to the console in the same if statement. So the second if statement is redundant.

That is what you meant right?

Steven Parker
Steven Parker
231,269 Points

I agree that seems a bit odd, you wouldn't do this in actual practice.

But I think this was done just to illustrate the use of Boolean values.

all right , thanks for the answer Steven: )