Introduction

JPigLatin is a translation and speech synthesis package

Netlify Status npm version

About

JPigLatin is a javascript package that takes plain text and converts it into pig-latin. Originally inspired by an episode of Stuff You Should Know, the project was created to learn more about developing packages on NPM.

How it works

The actual code is pretty simple. The main function encode accepts the ElementID’s of user-supplied input , proccesses it with simple pig-latin based rules, and returns the encoded output. Developers can set the output of encode using innerHTML to display the output. See quick start to see an example.

function encode(input,output) {
  var string = document.getElementById(input).value;
  var words = string.split(" ");
  var answer = "";
  var temp = "";
  for (var i = 0; i < words.length; i += 1) {
      temp = words[i].slice(1);
        if (typeof temp === 'undefined' || typeof words[i][0] === 'undefined') {
          break;
        } else {
          answer = answer + (temp.toLowerCase()+words[i][0].toLowerCase()+"ay") + " ";
        }
   }
    return answer;
 }

Contributing

Feel free to make a pull request for features

Edit this page on GitHub