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 trialhandy christian
2,899 PointsI dont get what this question mean, can somebody help me to explain this question?
Can somebody explain me how many blocks can run if we use if command?
1 Answer
Juan Lopez
Treehouse Project ReviewerIf you visualize the question
var x = 23;
if (x < 10) {
console.log("Your number is less than 10");
} else if (x < 20) {
console.log("Your number is greater than 10 but less than 20");
} else if (x < 30) {
console.log("Your number is greater than 20 but less than 30");
} else {
console.log("Your number is greater than 30");
The first if
statement is a code block, the first else if
is another code block, the second else if
is another code block, and lastly the else
is a code block.
So what is the maximum number of code blocks in that conditional statement that can RUN?( keep in mind once a condition/code block returns true then it will exit out of the conditional)
handy christian
2,899 Pointshandy christian
2,899 Pointsso the maximum code block will run is 1?
Juan Lopez
Treehouse Project ReviewerJuan Lopez
Treehouse Project ReviewerYup you got it.