I set myself a series of challenges to solve as part of learning to translate the compsci concepts I've learned into JavaScript terms. Thus far I've learned some methods and standard iterative techniques, but mostly I've learned that JavaScript has more curly brackets and semi-colons than any sane language should. (And I learned that it doesn't come with a real built-in method for sorting numerically, which was a bit of a strange discovery.) That said, here are some of the lovely things I've been able to do with it.

Bubble sort. I had no problem with this after I discovered that yes, JavaScript does indeed allow you to break loops with a keyword.

Finding perfect squares in an array. I did a pen-and-paper style search for this, finding first the factors of each number in the given array, then finding if any of those factors, when squared, equaled the original number, and pushing that squared factor to the placeholder array if found.

Checking if a given number is a power of 2. Another pen-and-paper search: taking a given number, I divide it by 2 until its quotient becomes 1—in which case it is a power of 2—or the quotient becomes an odd number—in which case it isn't. I'm proud of how simple this one is (even though its speed is probably very slow since it potentially will have to make many, many calculations).

Temperature conversion. I thought a lot of Ruby when building this one, for the object-oriented principles I learned thanks to Ruby. This sweet little algorithm takes a temperature and the type of scale into which the temperature is to be converted, and outputs the appropriate conversion based on that info.

Test for primeness. This does it the long way too: given a number, it generates a range of numbers from 1 to itself for it, then selects factors from that range. If the length of the factors array is 2, the number is prime.

Euclid's greatest common factor algorithm. I did this one in Ruby last week and decided to write it in JavaScript too, just to thumb my nose at the fact that front-end isn't supposed to use recursion due to the need to keep memory usage low.

That's all for today! I spent the rest of the day working on all sorts of other things that will probably get posted here soon too. Either way, conquering JavaScript one script at a time.