I have some bad habits. If/else works so never looked for the right way to do it. Can you show me an example of the better method?

thanks