(A New “Always 3” Script, yo!)

Remember how I made my first script called Always 3? In today’s lesson (which is really short, but a good lesson), we learned about refactoring your script. In short, rewrite the entire script in a much cleaner, easier to read/understand way. Using the cheat sheets and guidelines that were provided to us by the instructor, plus all the basics we’ve covered from last week and the ones from a few days ago, we were given two challenges on how to rewrite that same script in a much cleaner, easier-to-understand way.

The first challenge was to refactor the Always 3 script with only two variables instead of three (like the old one). This is what I got.

The second and final challenge is to refactor the Always 3 script with only one variable and three lines. At first, I thought it was impossible, and then I had to review the old script and the first refactoring challenge. Then I figured it out. This was a simple math/arithmetic problem that one thing flashed in my mind.

I tested both of them to be sure that they got the same result as the screenshot below from the previous entry from last Monday:


Moral lesson for today? There are several ways to solve a problem, especially in real life. It’s the same with programming and web development. Agree? 😊

On the sidenote…

  1. “Please excuse my dear Aunt Sally”. I was never good in math, let alone algebra or arithmetic, rather I never really liked math. But, I can never forget PEMDAS.