The IF statement and how to use it
Does programming involve a lot of IF statements or am I doing something wrong?
Think about it this way.
Learning to code is gathering tools, your if statements, functions, classes. That sort of stuff.
Programming is applying these tools in an appropriate way to solve your problem.
Now there are multiple appropriate ways to solve problems. Like “There are more than one ways to skin a cat”.
Now will all of these methods look pleasing or will some look like a hot mess?
A “good” programmer should be able to apply your tools in an appropriate manner to solve your problem.
If you can think that there is probably a simpler way to solve your problem, there probably is. That is when you need to look around and see what you can do.
More on reddit.comI think I use if statements too much
Is using "else if" actually discouraged?
Videos
Learn how to use the IF function, one of the most popular functions in Microsoft Excel. The IF function allows you to make logical comparisons between a value and what you expect. An IF statement can have two results. The first result is if your comparison is True, the second if your comparison is False.
For example, =IF(C2=”Yes”,1,2) means IF(C2 = Yes, then return a 1, otherwise return a 2).
https://youtu.be/sDT5D3WNQJw