I am starting a new mini series on JavaScript. I’m starting it from zero. Anyone can start learning from here. My goal is helping others while learning! I know about JavaScript and I’m working on a MERN tech stack. But I think it is not a bad idea to revise the JavaScript from scratch and helping others in this time. If you have any questions, shoot on the comment session or you can directly ask me in my social media. Social media links are in the last part of today’s lesson! Let’s learn JavaScript together.
More Conditional Statement — JavaScript Series — Part 9
A full series to learn the JavaScript from zero
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.
Originally it published on nerdjfpb blog. Check the git for codes.