JavaScript Exercise: Find the Number of Unique Letters in a String

Everyone once in a while it's good to complete a fun vanilla JavaScript exercise. One recent exercise I tried was to find the number of occurrences of each letter in specified string. The following was my method.

Introduction
For quite a long time now websites with the so called "parallax" effect have been really popular.
In case you have not heard of this effect, it basically includes different layers of images that are moving in different directions or with different speed. This leads to a...

Chances are that any Web designers using our Ghostlab browser testing app, which allows seamless testing across all devices simultaneously, will have worked with responsive design in some shape or form. And as today's websites and devices become ever more varied, a plethora of responsive images...

You've probably noticed that I shy away from writing really long articles. Here are a few reasons why:
Most site visitors are coming from Google and just want a straight to the point, bail-me-out ASAP answer to a question.
I've noticed that I have a hard time...

You've probably been to sites like RapidShare and MegaUpload that allow you to download files but make you wait a specified number of seconds before giving you the download link. I've created a similar script but my script allows you to animate the CSS font-size...

Discussion

Wes

This looks like the beginning of a simple javascript word game…you get the letters and amount of times they occur and then have to figure out the string.

This is probably self explanatory but it goes through and checks if the character is in the “uniq”ue string. If not, it adds it to the end. Then it just determines the length of the unique string, since all characters contained within are… unique. It’s basically the same as yours but it saves having to loop through the object keys just to get a count. I feel like there’s a regex way of doing this but I’m not sure how.

Rakesh Juyal [RJ]

Walsh, u certainly know how to perform the easiest task in the toughest way.

It iterates (in reverse) through the string and adds a new property of that character to the returned object. It iterates in reverse because that’s quicker than the alternative – i.e. having to check the length property on every iteration…