Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions 02week/PigLatin.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
1. find the first vowel
// if the first is a vowel, then you add "yay" to the end.
// example: egg -> eggyay
// if the first vowel is in the middle of the word,
// then you split the word, and swap the halves, and add "ay" to the end.
fox -> f ox -> oxf -> oxfay
//if the word doesnt have a vowel, you can make something up
44 changes: 43 additions & 1 deletion 02week/pigLatin.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,54 @@ const rl = readline.createInterface({
output: process.stdout
});

//this function will take in a word and returns the position of the first vowel
//if the word has no vowel, it return -1
function firstVowel(word){
let wordNew = word.toLowerCase().trim();
let vowels = "aeiou";
//loops thru whatever word is chosen to get translated
for(let i = 0; i < word.length; i++){
//needed to find a way to go thru every individual letter
let letter = word[i];
//needed to create the answer. this tells us wether it has a vowel or not
let answer = vowels.includes(letter);
//console.log(letter, " ", answer);
//console.log(i , " ", answer);
//if our answer is = to true it would return our i.
if(answer === true){
return i;
}//is this letter a vowel
}
//if you get to this point
//what does it mean? is it done running the loop, and did not return
//which means it did not find a vowel
return -1;
}

const pigLatin = (word) => {

// Your code here

//set a empty string
//set the first vowel into a variable
let position = firstVowel(word);
//console.log("position of the first vowel is", position)
//felt like it should have worked
if (firstVowel == true){
word += "yay";
return word;
} else if (firstVowel === -1){
let firstHalf = word.substring(0, position);
word = word.substring(firstVowel, word.length);
word = word + firstHalf;
word += "ay";
return word;

}


}

}


const getPrompt = () => {
Expand Down
1 change: 1 addition & 0 deletions 02week/tests.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

1 change: 1 addition & 0 deletions 03week/ticTacToe.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ function printBoard() {

function horizontalWin() {
// Your code here

}

function verticalWin() {
Expand Down