Avatar of brunnock

brunnock's solution

to Acronym in the JavaScript Track

Published at Aug 19 2018 · 0 comments
Test suite


This exercise has changed since this solution was written.

Convert a phrase to its acronym.

Techies love their TLA (Three Letter Acronyms)!

Help generate some jargon by writing a program that converts a long name like Portable Network Graphics to its acronym (PNG).


Go through the setup instructions for JavaScript to install the necessary dependencies:


Running the test suite

The provided test suite uses Jasmine. You can install it by opening a terminal window and running the following command:

npm install -g jasmine

Run the test suite from the exercise directory with:

jasmine acronym.spec.js

In many test suites all but the first test have been marked "pending". Once you get a test passing, activate the next one by changing xit to it.


Julien Vanier https://github.com/monkbroc

Submitting Incomplete Solutions

It's possible to submit an incomplete solution so you can see how others have completed the exercise.


var Acronyms = require('./acronym');

describe('Acronyms are produced from', function () {
  it('title cased phrases', function () {
    expect(Acronyms.parse('Portable Network Graphics')).toEqual('PNG');

  it('other title cased phrases', function () {
    expect(Acronyms.parse('Ruby on Rails')).toEqual('ROR');

  it('inconsistently cased phrases', function () {
    expect(Acronyms.parse('HyperText Markup Language')).toEqual('HTML');

  it('phrases with punctuation', function () {
    expect(Acronyms.parse('First In, First Out')).toEqual('FIFO');

  it('other phrases with punctuation', function () {
    expect(Acronyms.parse('PHP: Hypertext Preprocessor')).toEqual('PHP');

  it('phrases with punctuation and sentence casing', function () {
    expect(Acronyms.parse('Complementary metal-oxide semiconductor')).toEqual('CMOS');
class Acronyms {
  static parse(phrase) {
    phrase = phrase.replace(/([a-z])([A-Z])/g, "$1 $2");
    let words = phrase.split(/\W+/);

Community comments

Find this solution interesting? Ask the author a question to learn more.

What can you learn from this solution?

A huge amount can be learned from reading other people’s code. This is why we wanted to give exercism users the option of making their solutions public.

Here are some questions to help you reflect on this solution and learn the most from it.

  • What compromises have been made?
  • Are there new concepts here that you could read more about to improve your understanding?