Skip to content
33 changes: 30 additions & 3 deletions 02week/pigLatin.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
'use strict';

//global storage
//const pigLatinStr = ('choose your word here') => {}
//const vowels = ('aeiou')

//function names, purpose, method
//convert your word to lower case, toLowerCase method
//get rid of any empty space, trim method, chained to toLowerCase
//vowelIndex(), use this inside of a forEach method to find the index of the vowels in the word, indexOf method

const assert = require('assert');
const readline = require('readline');
const rl = readline.createInterface({
Expand All @@ -8,11 +17,29 @@ const rl = readline.createInterface({
});


function pigLatin(word) {
const pigLatin=(word)=> {
word.toLowerCase().trim();
const wordArr=word.split();
const vowel = ['a', 'e', 'i', 'o', 'u']
wordArr.forEach((letter, i) => {
if(vowel.indexOf(letter)!==-1){

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This block of code should be indented 2 spaces for readability.

return vowel;
}
});
//slice, indexOf, concat
//checkFirstVowel goes here!!!
let firstVowel;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

where is this being used? why is it declared here?

vowel.forEach=()=>
word.copyWithin(searchVowel[0], );

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be same line as 32

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what does the method copyWithin do?

//moveToEnd(), move consonants before the first vowel to the end of the word,
word.push(`ay`);
word.join(``);
return word;
}

pigLatin(`scram`);

// Your code here

}


function getPrompt() {
Expand Down