Exercism v3 launches on Sept 1st 2021. Learn more! ๐Ÿš€๐Ÿš€๐Ÿš€
Avatar of PatrickMcSweeny

PatrickMcSweeny's solution

to Acronym in the JavaScript Track

Published at Aug 21 2019 · 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:



Install assignment dependencies:

$ npm install

Making the test suite pass

Execute the tests with:

$ npm test

In the test suites all tests but the first have been skipped.

Once you get a test passing, you can enable the next one by changing xtest to test.


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.


import { parse } from './acronym';

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

  xtest('other title cased phrases', () => {
    expect(parse('Ruby on Rails')).toEqual('ROR');

  xtest('phrases with punctuation', () => {
    expect(parse('First In, First Out')).toEqual('FIFO');

  xtest('phrases with all uppercase words', () => {
    expect(parse('GNU Image Manipulation Program')).toEqual('GIMP');

  xtest('phrases with punctuation without whitespace', () => {
    expect(parse('Complementary metal-oxide semiconductor')).toEqual('CMOS');

  xtest('long phrases', () => {
    expect(parse('Rolling On The Floor Laughing So Hard That My Dogs Came Over And Licked Me'))

  xtest('phrases with consecutive delimiters', () => {
    expect(parse('Something - I made up from thin air')).toEqual('SIMUFTA');

  xtest('phrases with apostrophes', () => {
    expect(parse("Halley's Comet")).toEqual('HC');

  xtest('phrases with underscore emphasis', () => {
    expect(parse('The Road _Not_ Taken')).toEqual('TRNT');
const firstLetters = phrase =>
    .replace(/_|\'/g, "")

export const parse = phrase =>

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?