There are three ways you can write code to output what you want given some input, and here are some characteristics of each.
1. The “Easy” Way – this is generally the fewest lines of code, the shortest execution time, uses the most native functions available and is easiest to read
2. The “Hard” Way – the code is lengthy, needs a lot of code comments, is difficult to test and feels like its forced to get the correct result.
3. The “Wrong” Way – characteristics of either #1 or #2, and it throws an error.
The challenge is then finding the way from #2 to #1.