![]() ![]() const hasApples = 'true'Ī falsey value is a value that evaluates to false when converted into a boolean. If you write a single variable (like hasApples in the example below) as the condition of an if/else statement, JavaScript checks for a truthy or a falsey value. In this case, a = b evaluates to true because b now points to the same reference as a. The if/else statement helps to control what your program does in specified situations. Otherwise, continue walking”.Īnd that, my friend, is the foundation of an if/else statement. It sounds something like: “If the light turns red, stop walking. What do you do?Īnd what happens when the light turns green again? You start walking. You’re about to cross the road when you notice the traffic light for pedestrians turns red. Let’s say you’re walking on a busy street in the middle of town. Understanding if/else statements 22nd Nov 2017
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |