Problem Solving

A simple problem

This week we were learning about methods in JavaScript. These are functions that are built into the language for convenience and efficiency, because of how often they are used by developers.

One method I researched was the .sort() function.

This function takes a list or "array" of values and sorts them alphabetically. For example if we performed the .sort() method on this array:

[ 'Dr. Teeth' , 'Zoot' , 'Animal' , 'Floyd' , 'Janice' ]

It will become

[ 'Animal', 'Dr. Teeth', 'Floyd', 'Janice', 'Zoot' ]

I also expected that if passed an array of numbers, it would sort them numerically by size, however, when I performed the .sort() function on this array:

[ 150 , 32 , 345 , 1 , 95 , 40 ]

It became

[1, 150, 32, 345, 40, 95 ]

So I had to figure out why, and how to alter the method so that it could be used to sort the numbers by value.

After some research I found that the .sort() method sorts elements by the Unicode point value of the first character. 1 comes before 3, which is why 150 will come before 32.

I messed around for a while and eventually found a way to tell the method to treat each value as an integer instead of a Unicode character. By adding a function which compared each number by size, I was able to use the .sort() method to sort numbers by value.

Here is the original method, and my modified version for sorting numbers

array . sort ()
array . sort (( a , b ) => a - b )

This problem solving experience was a combination of trial and error, console logging, googling, and learning through reflection.

An elegantly solved problem

Something about me is, I really hate doing household chores. I don't understand how there are always so many of them. They take forever, they are monotonous, they are hard work and they never really feel like an accomplishment because
a. Everyone has to do them all the time (and somehow it seems like no one else is really complaining about it) and
b. There's no tangible evidence of your success because the next day the kitchen is full of dishes and the laundry is full of clothes all over again. Totally anticlimactic for something so treacherous.

For years I have stressed myself out, resenting doing these tasks, feeling like a whiny baby for finding them so difficult, and in awe of the many many people out there who have waaaaay more responsibilities than I do, who still somehow manage to keep their homes clean, tidy and organised.

Another thing about me is, I love watching television. Like, I know that basically everyone loves watching television but I /really/ love it. Especially reality TV. And one of the (many) great things about reality TV is, it doesn't really require your whole, undivided attention to get the picture of what's going on. There's no hidden meaning behind little clues on the screen. You're not gonna be sitting in forums for hours debating the symbolism of a specific lipstick smudge or literary reference. They even have talking heads of each person literally explaining what is going on in each scene just incase you missed something.

In the past I had tried motivating myself with a sweet treat or video game after completing my household tasks. But this didn't really work because, in my desire to reach the end goal quickly, I was inclined to cut corners and cheat myself out of doing the chore properly.

Then a few months ago, with a new season of Love Island on the horizon, I started thinking, what if I only allowed myself to watch the show WHILE I was doing household chores. If I stopped working, I would also have to stop watching. Obviously most shows only release one episode per week; definitely not enough time to do an entire week's worth of chores. But Love Island, bless their souls, provide us with a new, 1 hour, episode of bimbos and himbos floating through paradise SIX DAYS A WEEK.

So each day as I was excited to find out what dramas had unfolded in the villa, I also became, if not excited, at least extraordinarily neutral towards folding my laundry, cleaning my kitchen, tidying my living room. I am not exaggerating when I say that this decidedly elegant solution has changed my life and my relationship to chores for good.

Thank you to bimbos and himbos everywhere. Never stop being you. And please never stop making TV.

How confident do I feel using each of these problem-solving techniques/processes