Problem Solving

A time I got blocked on a problem:

What was the problem?

There was code that had door + hiding grouped together. Scooby was hiding behind some of the doors and I had to get the door number for each door Scooby was behind, then return it.
The structure was:

1 ----------------- List of doors ->
2 --------------------------------- door ->
3a ---------------------------------------- door number: "____"
3b ---------------------------------------- who is hiding behind the door: "____"

Before targeting the next door, I had to search within the current door to see if "hiding: ______" was Scooby. This had to be applied to every door in the list, regardless of how many there were. When Scooby was the name in hiding, I then had to get the door number at the same level. I found this confusing because of the 'objects' (pairs of information, such as "Name: Hannah"), being nested within arrays.

The thing that tripped me up was the fact that the test code (checking my answer) was running 3 times with 3 different lists. I had not checked this in the test code, so I thought that it was an extra level deep.
I was picturing it as:

1 ------------------ List of lists ->
2 ---------------------------------- List of doors ->
3 -------------------------------------------------- door ->
4a --------------------------------------------------------- door number: "____"
4b --------------------------------------------------------- who is hiding behind the door: "____"

Because of this misunderstanding, I was initially finding it impossible to correctly access the intended information.

What problem solving techniques did you use?

How did you feel throughout the process?

Frustrated, disheartened, confused, incapable. I honestly felt like I had made a mistake by doing this course and that I am not smart enough. I also felt like I had missed parts of the course somehow. It was such a simple thing to do, and I was struggling to do it. I had tried so many things, and was confusing myself more and more. I tried to remind myself that the discomfort of not knowing the answer is part of learning, but it did weigh on me.

What did you learn?

That I get too ahead of myself. I was looking at the problem as the big picture, I initially used console.log to see what data was being passed to the function (what list would be searched). This returned 3 lists, which I interpreted as a list of lists. I didn’t realise that the function was being called multiple times. When discussing the challenge with a peer, I was reminded to take it one step at a time and focus on the error message I was getting rather than the structure of the list I had seen from the console.log. My peer explained that if I look at the test code, I would see that the function is being called 3 separate times on 3 different lists. This removed a level from my understanding of the list structure and made it much easier for me.

A time I solved a problem in an elegant way:

What was the problem?

I needed to find all instances of the word “Buzz” in an array, no matter what case each of the letters was. The filter method is case-sensitive, so it could only pick up exact matches.
One option was to change every character to lower case and then revert it after the filter.

In the second array, two words contained characters in upper case, which means I would need to target those exact characters by index and make them upper case.
After some googling, I came across the option to filter so it is checking if the current word in all capitals matches the word ”buzz” in all caps (so “buzz” would become “BUZZ” and “buZZ”, “BuZz”, “Buzz”, etc would all match as they are also viewed as “BUZZ” during this filter search).

By doing this, I have prevented any accidental consequences of changing all characters and the difficulty of then targeting two specific characters and making them upper case again.
Doing this meant that the original casing was still intact, and the filtered, then joined, string matched the expected output.

What problem solving techniques did you use?

How did you feel throughout the process?

A little confused and uncertain. I was googling solutions and there are so many different ways to do things, I didn't know where to begin. I saw that a method that turns text to uppercase was in the list of methods we should use for this task, so I went with the method I explained above. If I had not come across it on google, I don't think I would have thought of it.

What did you learn?

Methods can be nested far more than I realised and I want to understand the structure of methods, functions, objects, and nesting in greater detail.

How confident I feel using each problem solving techniques/processes: