It's pronounced Diane. I do data architecture, operations, and backend development. In my spare time I maintain Massive.js, a data mapper for Node.js and PostgreSQL.
Defaulting to const declarations helps keep track of what's allowed to change. reduce is more appropriate when you need to accumulate results than the two-step of generating a new array and joining it. The hashtable lookup keeps the reducer body as short as possible, but there's nothing wrong with a switch per se.
I interned at NASA, working on statistical modeling and machine learning projects. Now I'm at Ferguson Enterprise, working on applying UX principles to internal tooling!
Defaulting to
const
declarations helps keep track of what's allowed to change.reduce
is more appropriate when you need to accumulate results than the two-step of generating a new array andjoin
ing it. The hashtable lookup keeps the reducer body as short as possible, but there's nothing wrong with aswitch
per se.Clever!
Thanks Dian!
@dmfay This is a very elegant solution! I like that you're explaining the reasons why you did things like use a
const
etc.One thing you didn't mention is the use of the spread syntax (
[...dna]
), which is definitely handy in JS when passing arrays around.wow I didn't know
would automatically turn your string into an array. I always use
I'm gonna change my solution to reflect this newfound knowledge.
Came to the comments to post this exact solution. Very elegantly done.