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 trialEsther AlQaisi
2,311 Points"Else" keyword not necessary ??
I'm wondering why there is no "else" clause in the "if" statement. Is it not necessary here? I was under the impression that all "if" statements needed at least one "else" clause that followed it. I'm thinking that's not correct. Someone clarify?
1 Answer
Shaun Kelly
35,560 PointsHi Esther,
an IF statement does not require an else clause. You can write an IF statement around a specific piece of code which will only run if the condition is met.
Hope this helps, Shaun
Esther AlQaisi
2,311 PointsEsther AlQaisi
2,311 Points100% Thank you