Back to articles
Stop Writing Bad JavaScript! Master if, else, and switch in 5 Minutes

Stop Writing Bad JavaScript! Master if, else, and switch in 5 Minutes

via Dev.to JavaScriptKunal

In our daily lives we make several decisions from deciding what to wear to deciding what to eat. In coding we have the same we call it Conditional Statements which is if , else and switch . In this Blog we will discuss about these Conditional statements . Topics to Cover What control flow means in programming The if statement The if-else statement The else if ladder The switch statement When to use switch vs if-else Control flow In programming , the computer does not randomly runs the code . It follows a flow deciding what to do next based on the condition. Think of a traffic signal If the light is green - Go If the light is yellow - Slow down If the light is red - Stop! Based on the condition you take the decision. So , Control flow simply mean the order in which a program runs instruction and make decision . The if statement The if statement is used to run some code only when the condition is true If statement consist of : In programming we write like this : const age = 20 if( age >=

Continue reading on Dev.to JavaScript

Opens in a new tab

Read Full Article
1 views

Related Articles