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 trialEnemuo Felix
1,895 PointsQuiz
Please can someone explain this to me. And secondly, What is a "code" block? Thanks in advance (https://teamtreehouse.com/library/javascript-basics/making-decisions-with-conditional-statements/review-else-if-clauses-and-javascript-comments)
2 Answers
Ari Misha
19,323 PointsHiya there! Everything that comes between "{ }"(curly braces) is a code block. And doesnt matter how many "if" and "else if" you have in your code , only one code block gets run. Conditional statements decide the flow of your application. They make decision for ya and everything statement in code block gets executed. I hope it helped. (:
Christopher De Lette
Courses Plus Student 7,139 PointsAccording to the link you posted you are wondering about comments in JavaScript. Using the // method is to comment out one single line of code, whereas the /* Comment here */ method is used to comment multiple lines of code and for me is what i use to test other parts of my code if i'm writing longer js programs.
As far as your second question a code block is nothing more than a block of code. JavaScript statements can be grouped together in code blocks, inside curly brackets {...}. For example say the following simple code has been written:
if (conditional statement) {
*your code here*
}
else {
*do something other than the first snippet of code inside my if statement*
}
There are two code blocks in this example and the purpose of code blocks is to define statements to be executed together. You can have any variation of a block of code, some longer and some many shorter. Hope this helps.
Thanks and Happy Coding! Chris
Christopher De Lette
Courses Plus Student 7,139 PointsChristopher De Lette
Courses Plus Student 7,139 PointsDidn't see your posting Ari as i was composing my answer too. You explained it to perfectly :)
Chris
Enemuo Felix
1,895 PointsEnemuo Felix
1,895 PointsThanks Chris and Ari for the help. I will really appreciate if you can explain this statement by Ari better "And doesnt matter how many "if" and "else if" you have in your code , only one code block gets run."