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
Waqar Ashraf
3,743 Pointswhat is true inside if condition
In line 131 there is if statement
function requiredFilledIn(){
if(true) $submit.attr("disabled",disabled);
else $submit.removeAttr("disabled");
}
I want to ask what is if(true) condition checks here ? I could not get true concept in this line here?
2 Answers
Michael Hulet
47,913 PointsIn JavaScript, if statements are executed if the parameter to the if statement returns true. So, for example, 5 > 3 would return true, 1 === 1 would return true, and 8 !== 4 would also return true. In this case, you're just passing the value true into the if statement. You're essentially just being very direct and saying "Yeah, the value's true. Just run the code". This causes the if statement to run every time (thereby making the if statement altogether unnecessary), but you'll never do that in an actual scenario.
Waqar Ashraf
3,743 PointsHi I know what if statement does but i did not understand here in this specific example of code it is in build an interactive website and video is Checking values . You can see it in line 131 .
geoffrey
28,736 Pointsgeoffrey
28,736 PointsCan I have the link to the exersice ?