Skip to content

Instantly share code, notes, and snippets.

@prio101
Created December 4, 2014 14:08
Show Gist options
  • Save prio101/1911ed5f8e88dc2e62c9 to your computer and use it in GitHub Desktop.
Save prio101/1911ed5f8e88dc2e62c9 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>JS Bin</title>
</head>
<body>
<script id="jsbin-javascript">
function pigLatin(phrase){
var words , pigged ;
//Look for the spaces among //the words and hold them
words = phrase.split(" ");
/*Loop over and translate it in latin*/
pigged = words.map(function(word){
var first , rest ;
// Grab the firts letter of the word
first = word.substring(0,1);
// Grab the last letter of the word
rest = word.substring(1);
//Start words with ending of the words and add up the
// first letter in the last of the words and add 'ay' after it
return rest+first+"ay";
});
//Print the new result
return pigged.join(" ") ;
}
pigLatin("Some Words Dont look fine in reverse way");
</script>
<script id="jsbin-source-javascript" type="text/javascript">function pigLatin(phrase){
var words , pigged ;
//Look for the spaces among //the words and hold them
words = phrase.split(" ");
/*Loop over and translate it in latin*/
pigged = words.map(function(word){
var first , rest ;
// Grab the firts letter of the word
first = word.substring(0,1);
// Grab the last letter of the word
rest = word.substring(1);
//Start words with ending of the words and add up the
// first letter in the last of the words and add 'ay' after it
return rest+first+"ay";
});
//Print the new result
return pigged.join(" ") ;
}
pigLatin("Some Words Dont look fine in reverse way");
</script></body>
</html>
function pigLatin(phrase){
var words , pigged ;
//Look for the spaces among //the words and hold them
words = phrase.split(" ");
/*Loop over and translate it in latin*/
pigged = words.map(function(word){
var first , rest ;
// Grab the firts letter of the word
first = word.substring(0,1);
// Grab the last letter of the word
rest = word.substring(1);
//Start words with ending of the words and add up the
// first letter in the last of the words and add 'ay' after it
return rest+first+"ay";
});
//Print the new result
return pigged.join(" ") ;
}
pigLatin("Some Words Dont look fine in reverse way");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment