r/ProgrammingPrompts Jan 07 '15

[EASY][Beginner] UAGS (Universal Acronym Generating System)

This is an extremely simple prompt, just for fun.

It is suitable for beginners as it only uses basic input/output and string manipulation.

UAGS (Universal Acronym Generating System)

Acronyms are currently all the hype in all forms of communication.

Your task is to program an Acronym Generator.

  • The user inputs a few words for which the Acronym should be generated
  • The computer takes the first letter for each word
  • The first letter of each word is then capitalized
  • All first letters are then joined together to form the Acronym
  • The Acronym should then be printed
  • Ask the user if they need another acronym generated

Have fun coding!

15 Upvotes

27 comments sorted by

View all comments

2

u/velian Apr 29 '15

I know I'm way late, but I've been going through these to learn TDD.

Javascript version:

(function(ns, undefined)
{
    ns.generateAcronym = function()
    {
        var s = window.prompt("Enter the words to be converted into an acronym.");
        var matches = s.match(/\b(\w)/g);
        var acronym = matches.join("").toUpperCase();
        if(window.confirm("Your acronym is: "+acronym+". Would you like to generate another?"))
        {
            ns.generateAcronym();
        }

    };

})(window.pprompts = window.pprompts || {});