Skip to content

Instantly share code, notes, and snippets.

@alex-hladun
Created May 25, 2020 23:06
Show Gist options
  • Save alex-hladun/3a257d44a7efc8ed2ecd47adfc21b0d6 to your computer and use it in GitHub Desktop.
Save alex-hladun/3a257d44a7efc8ed2ecd47adfc21b0d6 to your computer and use it in GitHub Desktop.
Creates a pig latin representation of a string using node command-line arguments.
const args = process.argv.slice(2);
let str = "";
for (let i = 0; i <= args.length - 1; i++) {
let phrase = "";
let firstLetter = "";
for (let j = 0; j <= args[i].length - 1; j++) {
if (j === 0) {
firstLetter = args[i][0];
} else {
phrase += args[i][j];
}
}
phrase += firstLetter;
str += phrase + "ay ";
}
console.log(str);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment