Working through another set of small algorithmic challenges in order to bootstrap my JavaScript literacy! Today's problems include a pretty long solution to finding the mode in a given array, and the Look-Say sequence.

Mode. This problem gave me, well, problems. I used a JavaScript object like a hash to store values, but getting them back was messy as I'm still unused to the syntax. In the end it was a long, drawn-out affair in three parts: generating a hash of the given numbers with their respective counts, determining the element with the highest count, and generating a new array containing the numbers whose counts were equal to the highest count.

Look-Say Sequence. The idea for this one is for the program to look at a given number, extract it from the series, and record how many times it is repeated. So the number 1 returns 11, because there was one 1 in the original number; the number 338862222 returns two 3s, two 8s, one 6, and four 2s, or 23281642.

Doing these kinds of algorithms all week has really helped me to get comfortable with JavaScript, I think. It's how I initially learned Ruby: first learn enough syntax to solve algorithms, then solve a whole bunch of them, then read textbooks to understand what is happening and what else I should think about to start building on top of the small but stable amount of knowledge that I have. I read somewhere about a dev who has a series of go-to challenges for solving when learning new languages, and although I originally thought that something like that wouldn't be enough, now it feels a bit different.