@mpmanning108/

PigLatinTranslator

JavaScript

No description

fork
loading

This Plugin Crashed!

Error: Error: must not create an existing file {"type":"CREATE_FILE","wid":"0.4594852839602004","path":"main.js","file":{"path":"main.js","content":{"asEncoding":{"base64":"ZnVuY3Rpb24gUGlnTGF0aW5UcmFuc2xhdG9yKGFuc3dlcikgewogIHZhciB2b3dlbDEgPSBhbnN3ZXIubWF0Y2goL1thZWlvdXlBRUlPVVldLykuaW5kZXg7CiAgdmFyIHN0ZXAxID0gYW5zd2VyLnN1YnN0cmluZyh2b3dlbDEpOwogIHZhciBzdGVwMiA9IGFuc3dlci5zdWJzdHJpbmcoMCwgdm93ZWwxKTsKICBpZiAoc3RlcDIubGVuZ3RoID09PSAwKSB7CiAgICByZXR1cm4gc3RlcDEgKyBzdGVwMiArICd5YXknOwogIH0gZWxzZSByZXR1cm4gc3RlcDEgKyBzdGVwMiArICdheSc7Cn0KCnZhciBpbnB1dCA9IHdpbmRvdy5wcm9tcHQoJ2VudGVyIHRoZSB3b3JkKHMpIHlvdSB3YW50IHRyYW5zbGF0ZWQnKTsKdmFyIG91dHB1dCA9ICcnOwp2YXIgd29yZGxpc3QgPSBpbnB1dC5zcGxpdCgnICcpOwpmb3IgKHZhciB3b3JkcyA9IDA7IHdvcmRzIDwgd29yZGxpc3QubGVuZ3RoOyB3b3JkcysrKSB7CiAgb3V0cHV0ID0gb3V0cHV0ICsgUGlnTGF0aW5UcmFuc2xhdG9yKHdvcmRsaXN0W3dvcmRzXSk7CiAgb3V0cHV0ID0gb3V0cHV0ICsgJyAnOwp9CnZhciBzcGVhayA9IHdpbmRvdy5zcGVlY2hTeW50aGVzaXM7CgpzcGVhay5zcGVhayhuZXcgU3BlZWNoU3ludGhlc2lzVXR0ZXJhbmNlKG91dHB1dCkpOwphbGVydChvdXRwdXQpOwo="},"asBuffer":null},"loaded":true}}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
function PigLatinTranslator(answer) {
  var vowel1 = answer.match(/[aeiouyAEIOUY]/).index;
  var step1 = answer.substring(vowel1);
  var step2 = answer.substring(0, vowel1);
  if (step2.length === 0) {
    return step1 + step2 + 'yay';
  } else return step1 + step2 + 'ay';
}

var input = window.prompt('enter the word(s) you want translated');
var output = '';
var wordlist = input.split(' ');
for (var words = 0; words < wordlist.length; words++) {
  output = output + PigLatinTranslator(wordlist[words]);
  output = output + ' ';
}
var speak = window.speechSynthesis;

speak.speak(new SpeechSynthesisUtterance(output));
alert(output);
Native Browser JavaScript