Skip to content
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ Exercises are outlined in the `index.js` file, please read the instructions care

Using VSCode and Command Line:

1. Fork repo and add TL as collaborator on Github.
2. Clone your fork (not Lambda's repo by mistake!).
3. `cd` into your newly cloned repository.
4. Create a new branch by typing `git checkout -b <firstName-lastName>`.
1. [X] Fork repo and add TL as collaborator on Github.
2. [X] Clone your fork (not Lambda's repo by mistake!).
3. [X] `cd` into your newly cloned repository.
4. [X] Create a new branch by typing `git checkout -b <firstName-lastName>`.

### Task 2: Complete MVP Requirements

Expand All @@ -55,9 +55,9 @@ After you have completed the requirements, try any of the following challenges.

Follow these steps for completing your project.

1. [ ] Submit a pull request to merge `<firstName-lastName>` branch into master. **Please don't merge your own pull request**
2. [ ] Add your TL as a reviewer on the pull-request
3. [ ] Your TL will count the project as complete by merging the branch back into master
1. [X] Submit a pull request to merge `<firstName-lastName>` branch into master. **Please don't merge your own pull request**
2. [X] Add your TL as a reviewer on the pull-request
3. [X] Your TL will count the project as complete by merging the branch back into master

## Resources

Expand Down
176 changes: 152 additions & 24 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,35 +1,45 @@
/************************************************************** Task 1: Warm-up! **************************************************************/
//Task a: declare a variable called votingAge, console log true if age > 18 (no function required)

let votingAge = 17;



if(votingAge > 18){
console.log('true');
} else {
console.log('false');
}

//Task b: declare a variable and then use a conditional to change the value of that variable based on the value assigned to a second variable (no function required)

let age = 24;

age = age * 2;


console.log(age);

//Task c: Convert string ("1999") to integer (1999) (no function required) // hint look up the Number method



console.log(parseInt("1999"));


//Task d: Write a function to multiply a*b

function multiply(a,b){
return a * b;
}



console.log(multiply(2,3));

/************************************************************** Task 2 **************************************************************/
//Age in Dog years
//write a function that takes your age and returns it to you in dog years - they say that 1 human year is equal to seven dog years

function dogYears(age){
return age * 7;
}



console.log(dogYears(24));

/************************************************************** Task 3 **************************************************************/
//Dog feeder
Expand All @@ -49,9 +59,29 @@

// when you are finished invoke your function with the weight of 15 lbs and the age of 1 year - if your calculations are correct your result should be 0.44999999999999996




function food(pounds, age){
if (age >= 1){
if (pounds <= 5){
return pounds * .05;
} else if (pounds >= 6 && pounds <= 10){
return pounds * .04;
} else if (pounds >= 11 && pounds <= 15){
return pounds * .03;
} else {
return pounds * .02;
}
} else {
if (age >= .167 && age < .333){
return pounds * .1;
} else if (age >= .333 && age < .583){
return pounds * .05;
} else {
return pounds * .04;
}
}
}

console.log(food(15, 1));

/************************************************************** Task 4 **************************************************************/
// Rock, Paper, Sissors
Expand All @@ -60,31 +90,66 @@
// use math.random to determine the computers choice
// hint while you can complete this with only conditionals based on strings it may help to equate choice to a number

let computerPlay = Math.floor(Math.random() * 3);

let computerChoice = computerPlay


function roeShamBoe(computerChoice, userChoice){
if (computerChoice === 2 && userChoice === 2){
return 'It is a tie! Try again.';
} else if (computerChoice === 2 && userChoice === 1){
return 'You lose... Scissors beats Paper.';
} else if (computerChoice === 2 && userChoice === 0){
return 'You WIN! Rock beats Scissors.';
} else if (computerChoice === 1 && userChoice === 2){
return 'You WIN! Scissors beats Paper.';
} else if (computerChoice === 1 && userChoice === 1){
return 'It is a tie! Try again.';
} else if (computerChoice === 1 && userChoice === 0){
return 'You lose... Paper beats Rock';
} else if (computerChoice === 0 && userChoice === 2){
return 'You lose... Rock beats Scissors';
} else if (computerChoice === 0 && userChoice === 1){
return 'You WIN! Paper beats Rock.';
} else if (computerChoice === 0 && userChoice === 0){
return 'It is a tie! Try again.';
} else {
return 'This should have never happened. Please try again.'
}
}

console.log(roeShamBoe(computerChoice, 2));

/************************************************************** Task 5 **************************************************************/
//Metric Converter
//a. KM to Miles - should take the number of kilometers and convert it to the equal number of miles

function metricConverter(kilometers){
return kilometers * 0.621371;
}



console.log(metricConverter(5));

//b. Feet to CM - should take the number of feet and convert it to the equal number of centimeters

function feetToCm(feet){
return feet * 30.48;
}



console.log(feetToCm(5));

/************************************************************** Task 6 **************************************************************/
// 99 bottles of soda on the wall
// create a function called annoyingSong
// the function should take a starting number as an argument and count down - at each iteration it should log (number) bottles of soda on the wall, (number) bottles of soda, take one down pass it around (number left over) bottles of soda on the wall`

function annoyingSong(num){
for(i = 99; i > 0; i--){
console.log(i + ' bottles of soda on the wall, ' + i + ' bottles of soda, take one down, pass it around, you got ' + (i - 1) + ' bottles of soda on the wall.');
}
}



console.log(annoyingSong(99));

/************************************************************** Task 7 **************************************************************/
//Grade Calculator
Expand All @@ -95,24 +160,87 @@
//60s should be D
//and anything below 60 should be F




function grades(num){
if (num >= 90){
return 'A';
} else if (num < 90 && num >= 80){
return 'B';
} else if (num < 80 && num >= 70){
return 'C';
} else if (num < 70 && num >= 60){
return 'D';
} else {
return 'F';
}
}

console.log(grades(95));

/************************************************************** Stretch **************************************************************/
//Create a function that counts the number of vowels within a string. It should handle both capitalized and uncapitalized vowels.
// Hint - you may need to study tomorrow's traning kit on arrays
// try looking up the .includes() method

const vowels = ['a', 'e', 'i', 'o', 'u'];

function vowelCount(string){
let counter = 0;
for (let letter of string.toLowerCase()){
if (vowels.includes(letter)){
counter++
}
}
console.log(`The text contains ${counter} vowel(s)`);
return counter;
}


vowelCount('Nittacus Wittacus.');

/************************************************************** Stretch **************************************************************/
//Take Rock, Paper, Sissors further
//update your rock papers sissors code below to take a prompt from a user using the window object



let computerPlay2 = Math.floor(Math.random() * 3);

let computerChoice2 = computerPlay2

let userChoice2 = prompt('Enter your Choice!').toLowerCase();

console.log(computerChoice2, userChoice2);

function roeShamBoe2(computerChoice2, userChoice2){
if(userChoice2 == 'rock'){
userChoice2 = 0;
} else if (userChoice2 == 'paper'){
userChoice2 = 1;
} else if (userChoice2 == 'scissors'){
userChoice2 = 2;
} else {
return 'Do you even know how to play Rock, Paper, Scissors?';
}
if (computerChoice2 === 2 && userChoice2 === 2){
return 'It is a tie! Try again.';
} else if (computerChoice2 === 2 && userChoice2 === 1){
return 'You lose... Scissors beats Paper.';
} else if (computerChoice2 === 2 && userChoice2 === 0){
return 'You WIN! Rock beats Scissors.';
} else if (computerChoice2 === 1 && userChoice2 === 2){
return 'You WIN! Scissors beats Paper.';
} else if (computerChoice2 === 1 && userChoice2 === 1){
return 'It is a tie! Try again.';
} else if (computerChoice2 === 1 && userChoice2 === 0){
return 'You lose... Paper beats Rock';
} else if (computerChoice2 === 0 && userChoice2 === 2){
return 'You lose... Rock beats Scissors';
} else if (computerChoice2 === 0 && userChoice2 === 1){
return 'You WIN! Paper beats Rock.';
} else if (computerChoice2 === 0 && userChoice2 === 0){
return 'It is a tie! Try again.';
} else {
return 'This should have never happened. Please try again.';
}
}

console.log(roeShamBoe2(computerChoice2, userChoice2));