I felt very convinced throughout much of this challenge that there must be much more succinct ways to write this, and tantalized by that possibility because my own code, through my panic, was sort of difficult for me to read.
I’m not sure why I panicked, but at a certain point I did and it was sort of hard to put that cat back in the box.
The results of panicking
Jumping around a lot
Not always communicating what I was trying to do
Being less willing to take a moment write out pseudocode or consider alternative solutions
I did this once during an interview with Dealops as well.
Attempt 2
Turns out there were a tone of things I did that made things harder on myself.
This insistence on returning back to this continually updated array of values made my process more difficult to reason about. It was sort of like, “data hoarding” - I wanted to do ETL and transform data in as many discrete steps as possible. But this is a great example of how the exact opposite is much simpler, because data structures and loops are
Generally verbose
specifically some of the hardest bits of syntax to reason about
especially if there are similar ones lying around
Some very simple regex, namely someValues.match(/\d/g) really helped simplify things.
I’ll be honest though, I still struggled a bit. Mostly what I struggled with was
Handling when foundDigits.length didn’t exist
I was trying to conditionally use it in some cases and others, until I introduced if (foundDigits.length <= 0) continue, which simplified everything into one convenient conditional
But that still leaves me feeling that I should probably get to the bottom of someArray.length.
'moose'.length
// 3
let monkeys = []
monkeys.length
// 0
Hmm. Well these things are pretty straightforward. What about this:
''.length
// 0
Also zero. Man, what was I struggling with here? This is all very straightforward?