More Conditional Statement – JavaScript Series – Part 9
Muhammad Ali (Nerdjfpb) - Jan 30 '20 - - Dev Community
In last part we didn’t talk much about conditions. In this part we are going to talk about the conditions.
Suppose we need to found a value which is divisible by 5 and 7 both. How can we do this? The straight forward way will be just write one if inside of another one. Example –
Now we can do two conditions in one if. By adding && we can do it. Adding && means we need to satisfy both conditions to go that block. Example –
Now lets suppose we a string value which is midoriya or todoroki. If we get any of these, then we’ll tell this is coming from BHNA anime, or else we will print, we don’t know the sources. Let’s do it.
First we need a name variable and store the value in it –
Now lets check the both condition and put || between them. This means OR. If any of these condition approved, then if block will run.
So this was easy right ?
We learned about && which means and. Also we learn about || which means or.
Let me know if you have any questions.
You can see the graphical version here
Source Codes - { Check commits }
A tutorial for JavaScript Beginners
javaScript-Series
A tutorial for Absolute Beginners of JavaScript.
You can find the total pdf in - Here
You can check the commits to find the part by part codes.
Blogs
-
Day 1 - What is JavaScript?
-
Day 2 - JavaScript Types?
-
Day 3 - Javascript Types Cont.
-
Day 4 - Javascript Types Cont.
-
Day 5 - Javascript Comparisons
-
Day 6 - Javascript Variables
-
Day 7 - More About Variables
-
Day 8 - Conditional Statement
-
Day 9 - More Conditional Statement
Originally it published on nerdjfpbblog. You can connect with me in twitter or linkedin!