I was creating the the whereAreYou(arr) function. The function takes in an array and finds ‘Scooby’ behind a door.
The problem solving technique I used was console logging and reading error messages.
The objects look like so:
{door: 1, hiding: ‘Scooby’}
I console logged all objects in the array and found that I was getting undefined objects.
I looked down into the testcode and found that empty arrays were being tested. So I did a sanity check for empty arrays at the start of the function like so: (example in pseudo code)
if array length is 0, return 0.
I thought my solution was complete but I had an error which says that I cannot get property door from undefined. I had a suspicion that an empty array was the case but wanted to be sure.
Fizzbuzz is a simple problem common in programing challenges. For this version the function fizzBuzz should return "Fizz", "Buzz" and "FizzBuzz" for multiples of 3,5 and 15 respectively
I wanted to make fizzbuzz more readable
I used the rubber ducky method but even though I don’t have a rubber ducky. I used my teacup.
I separated the logic from the forloop in the form of a helper function
getFizzBuzz(number):
I created 3 variables holding the true/false values for multiple or 3, 5 and 15. This made it easy to create 3 if else statements like so in pseudo code:
const isMultiple3 = number % 3 === 0;
const isMultiple5 = number % 5 === 0;
const isMultiple15 = isMultiple3 && isMultiple5;
if (isMultiple15){
    return "FizzBuzz";
} else if (isMultiple3){
    return "Fizz";
} else if (isMultiple5){
    return "Buzz";
}
return number;
I could have utilized map() built in functions but it may have made it less readable. Doesn't mean I know it doesn't mean I should