Problem Solving
Simple problems
The other day I found myself stuck on a simple problem. I was creating a function that would loop through some data and put them into an object. The problem I was having was that the object that I was trying to put the data into wasn't going in. To solve this issue I turned to the holy console. I looked over at the console and checked the errors. When I looked I saw that the console was telling me that the a variable was not defined. Amazing my code doesn't work because something that I have defined, apparently isn't. So I took a look and noticed that I was calling it as if it was a method so the computer didn't know what was happening. I just had to move it to the left a bit. From this problem I learned that the errors in the console are a very powerful tool that are designed to help you when you are stuck and they should always be looked at when you are stuck.
A Time I Elegantly Solved a Problem
While completing the Super FizzBuzz challenge I elegantly solved the problem of creating the Super FizzBuzz function. Earlier I was asked to create a function called fizzbuzz that took in numbers and return values depending on what the number was. This was done using a few if statements. The Super FizzBuzz function was supposed to do the same thing, but instead it should iterate through an array of numbers. I solved this using the fizzBuzz function that was already made. In my for loop I pushed the array numbers into a new array and used fizzbuzz to check what their value was and return the correct things. This removed about 6 lines of re-written code, making the funciton more compact and easier to read. What I learned by doing this was how you can re-use functions in a way to reduce the amount of code you need to write so you don't repeat yourself.