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.