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
36 changes: 34 additions & 2 deletions 01week/rockPaperScissors.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,45 @@ const rl = readline.createInterface({
output: process.stdout
});


// the function that will be called by the unit test below
const rockPaperScissors = (hand1, hand2) => {
// create hands than correct is it has lowercase or whitespace
// need to get white space away as well as lowercase the word
let scrubHand1 = hand1.toLowerCase().trim();

let scrubHand2 = hand2.toLowerCase().trim();

//need to compare hand1 to hand2 and if its the same its a tie
//I tried to replicate the whiteboading video but for some reason i wasn't able to achieve
if (scrubHand1 === scrubHand2){
return "It's a tie!"
}
if (scrubHand1 === "rock" && scrubHand2 === "paper"){
return 'Hand two wins!'
}

// Write code here
// Use the unit test to see what is expected
if (scrubHand1 === "rock" && scrubHand2 === "scissors"){
return 'Hand one wins!'
}

if (scrubHand1 === "paper" && scrubHand2 === "rock"){
return "Hand one wins!"
}
if (scrubHand1 === "paper" && scrubHand2 === "scissors"){
return 'Hand two wins!'
}
if (scrubHand1 === "scissors" && scrubHand2 === "rock"){
return "Hand two wins!"
}
if (scrubHand1 === "scissors" && scrubHand2 === "paper"){
return "Hand one wins!"
}
}





// the first function called in the program to get an input from the user
// to run the function use the command: node main.js
Expand Down
23 changes: 21 additions & 2 deletions 02week/pigLatin.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,29 @@ const rl = readline.createInterface({
output: process.stdout
});


const pigLatin = (word) => {
//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){
//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;
}

// Your code here

}

Expand Down
38 changes: 38 additions & 0 deletions 02week/practice.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
'use strict'

let word = "elephant";
let vowels = "aeiou";



function firstVowel(word){
//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(answer === true){
return i;
}
}
}

let position = firstVowel("christopher");
console.log("position of the first vowel", position);






// Pig Latin
// 1. find the first vowel
// if the first letter 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 yay to the end
// fox -> f ox -> oxf -> oxfay
// if the word does not have a vowel, you can make something up