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 trialHunter Christian Davis
2,813 PointsCan someone explain in more depth as to why he is able to put false and it reads the else statement
I do not get the concept as it is not really explained
2 Answers
Mohammed Khalil Ait Brahim
9,539 PointsWell The thing is in an if else block the if block is only executed if the condition it holds evaluates to true so if the condition evaluates to false which is the case here we go directly to execute the statements in else block
if( true ) {
// EXECUTE THIS
}
else {
// THIS WILL NOT BE EXECUTED
}
if( false ) {
// THIS WILL NOT EXECUTE
}
else {
// EXECUTE THIS
}
Adam Oliver
8,214 PointscorrectGuess must = something. You assign it false by default, that way it can only be changed to true if the player guesses correctly. ELSE it stays as it was (false).
Hunter Christian Davis
2,813 PointsHunter Christian Davis
2,813 Pointsthank you ... that is what I was looking for
Stephen Petruzziello
7,084 PointsStephen Petruzziello
7,084 PointsSometimes you just gotta go forward in the teaching to see how and why things are used.
Isaac Al-Wahaibi
6,522 PointsIsaac Al-Wahaibi
6,522 Pointsthat was so helpful ,, thanks Mohammed