hello guys welcome to the next blog  on JavaScript tutorial for beginners in this blog we will learn about if else statement in JavaScript and how to use some of the comparison operators in JavaScript so let's get started so first of all why do we need to use FL statements so sometimes in your code you need to use some conditions on the basis of which you want to execute some code and if-else statement will help you to do exactly that so for example I want to check the age of the person if it's greater than 18 equal to 18 or less than 18 okay so I have a variable called age whose value initially I assign is equal to 18 okay and to check whether it's 18 or it's below 18 or it's greater than 18 you want to check it and then execute some code okay so you can use if statement for that and the basic syntax for if statement is if keyword and then these brackets and then these curly braces and in here in these round bracket your condition will be evaluated and if this condition in these bracket are met then this code is executed inside these curly braces okay so let's check the condition okay so I have this variable called age and I want to check whether it's equal to 18 or not so I just give these two equal to sign and I evaluate against 18 now these double equal to means equality okay so this is for checking the equality this single equal to is the assignment operator right and these double equal to is the equality checking operator okay so if this condition is met then we want to execute some code for example we want to print something using document dot right and we will say the age is equal to 18 okay and save your code and refresh your web page here and it says the age is equal to 18 okay now let's say in the case when this age is not equal to 18 we want to execute some other code so in that case we use else condition so just write else and then these curly braces okay so when this condition in if statement is not true your program logic comes to as condition and it executes the code which is inside these curly braces after else okay so I will just copy this here and I say age is not equal to 18 and let's say right now the age is 20 we assign age is equal to 20 and save it and refresh your webpage and now it says age is not equal to 18 okay now not only you can use equality here you can also compare non equality for example I want to compare non equality I give this exclamation mark and then this equal to sign and I can save it and I can refresh my webpage and it says the age is equal to 18 okay which is here okay so I'm checking whether my age is not equal to 18 and right now the age is equal to 20 right so it goes here because the condition is true with because 20 is not equal to 18 so it prints this statement okay now there are few operators which are called comparison operator which you can use in place of these equal and non equal signs okay so let's see what are they so these are some of the comparison operator we can use in JavaScript so we have already seen how to check equality now let's see what does these triple equal to do okay so for example I have age is equal to 18 here and I want to check if our age is equal to 18 obviously this will print this statement because this condition is true now we all know that right now age is a integer variable because we have assigned a number to it now let's see and check whether it gives this statement if we compare this age against a string value right so just save it and refresh our webpage and it says the age is equal to 18 right so right now this double equal to only checks the value and not the type of your value but when you use triple equal to it will check the value as well as the type of your variable okay so now let's see what happens so save it and refresh our page and now it says the age is not equal to 18 because these triple equal to is checking whether the value is 18 which is yes it's 18 but the type is string right and we are checking it against a number so then it will go here because this condition is not met okay so this is how you can use triple equal to non equality we have already seen this exclamation mark with double equal means we are checking non equality in value and non equality in type also okay now the next symbol is for checking if the value is greater than the value so for example we can use these angle brackets and here we use the number for example 18 once again and let's change this print message here so we can say age is greater than 18 and here we can say age is less than 18 okay and save your code and refresh your page and it says age is less than 18 right which is this statement because in our case age is equal to 18 and not greater than 18 right now the next symbol is to check whether age is greater than or equal to okay so you can use this and after this you can use equal to sign and then it will check if age is greater than or it is equal to 18 right so save your code and refresh your webpage and now it says the ages greater than 18 we must add this equal to symbol also here like this so this message is more clear right now in the same way we have the less than symbol so whenever you use here the less than symbol then it checks whether age is less than or equal to 18 okay so let's save it and refresh your code and now it says the ages greater than or equal to 18 which is this statement okay now let's say you want to check multiple conditions so how you can do this so in JavaScript you can also use nested if-else statement so for example here I'm checking if the value is 18 and if the value is 18 I will say value is equal to 18 and then I also want to check if the value is greater than 18 or not so after this curly braces we're this curly brace and and before the else condition I can introduce one more if condition like this and then you can do something like this and here you can add a keyword called else okay so it checks this condition else if this condition is true then it this statement will be executed else otherwise this statement can be executed so let's say we want to check if age is greater than 18 or not okay so copy it here and let's replace with greater than okay and let's say age is equal to 20 this time okay so refresh your webpage and now it says the age is greater than 18 so what is our program flow our program goes to if condition and checks where the 20 is equal to 18 or not which is not so it goes to next step and it checks this condition and check whether 20 is greater than 18 or not which is true so it executes this statement and it don't need to go to the third statement because this is already true right so in this way you can also use if-else statement in nested format okay so in this way you can use FL statement in JavaScript and you can use these comparison operators in JavaScript I hope you enjoyed this blog