Skip to content
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"liveServer.settings.port": 5501
}
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ 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
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. [ ] Your TL will count the project as complete by merging the branch back into master

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



let votingAge = 19;
// if (votingAge > 18) {
console.log(votingAge < 18);
// }


//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 a = 100;
let b = 50;
if (a > b) {
a = a - b;
}
else {
a = a + b;
}



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



console.log(Number('1999'))


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

function numMulti(a, b) {
return a * b; // place return infront of variables you would like to compute
}



console.log(numMulti(1,5))

/************************************************************** 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

// 1 year = 7 years in dogs

// 36 * 7 = 252

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

console.log(dogYears(36))

/************************************************************** Task 3 **************************************************************/
//Dog feeder
Expand All @@ -48,8 +65,36 @@
// 7 - 12 months 4% of their body weight

// 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 dogFeeder(pounds, age) {
if (age >= 1) {
if (pounds <= 5) {
return 0.05 * pounds;
} else if (pounds >= 6 && pounds < 10) {
return 0.04 * pounds;
} else if (pounds >= 11 && pounds <= 15) {
return 0.03 * pounds;
} else {
return 0.02 * pounds;
}
}

// 1 month = 1/12 year = 0.0833333333.....

else if (age < 1) {
if (age < (2/12) ) {
console.log("Feed from mother");
} else if ((age >= (2/12)) && (age < (4/12))) {
return 0.10 * pounds;
} else if ((age >= (4/12)) && (age < (7/12))) {
return 0.05 * pounds;
} else {
return 0.04 * pounds;
}
}
}

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



Expand All @@ -60,29 +105,93 @@
// 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



// var myChoice = prompt("Rock, paper, or scissors?");

let myChoice

function rps (myChoice) {
let cpuRandom = Math.floor(Math.random() * Math.floor(3))

if (cpuRandom === 0){
cpuRandom = "rock";
console.log("Computer: Rock");
}
else if (cpuRandom === 1){
cpuRandom = "paper";
console.log("Computer: Paper");
}
else {
cpuRandom = "scissors";
console.log("Computer: Scissors");
}

if (myChoice === cpuRandom) {
console.log("You: " + myChoice)
console.log("Tie.");
}
else if (myChoice === "rock" && cpuRandom === "paper") {
console.log("You: Rock");
console.log("You lose.");
}
else if (myChoice === "rock" && cpuRandom === "scissors") {
console.log("You: Rock");
console.log("You win.");
}
else if (myChoice === "paper" && cpuRandom === "scissors") {
console.log("You: Paper")
console.log("You lose.");
}
else if (myChoice === "paper" && cpuRandom === "rock") {
console.log("You: Paper");
console.log("You win.");
}
else if (myChoice === "scissors" && cpuRandom === "rock") {
console.log("You: Scissors")
console.log("You lose.");
}
else {
console.log("You: Scissors");
console.log("You win.");
}

}

rps()


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

// 1 KM = 0.621371 Mile

function convertToMiles(num1) {
return num1 = num1 * 0.621371;
}


console.log(convertToMiles(1));

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

// 1 FT = 30.48

function convertToCM(num1) {
return num1 = num1 * 30.48;
}


console.log(convertToCM(2));

/************************************************************** 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() {
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, ${i -1} bottles of soda on the wall..."`);
}

annoyingSong()



Expand All @@ -94,8 +203,31 @@
//70s should be Cs
//60s should be D
//and anything below 60 should be F



function gradeCalc(num) {
if (num >= 90){
return "A";
}
else if (num >= 80) {
return "B";
}
else if (num >= 70) {
return "C";
}
else if (num >= 60) {
return "D";
}
else if (num < 60) {
return "F";
}
else {
return "Please enter a number."
}

}

console.log(gradeCalc(79))



Expand All @@ -104,8 +236,25 @@
// Hint - you may need to study tomorrow's traning kit on arrays
// try looking up the .includes() method

let vowels = ["a","e","i","o","u","A","E","I","O","U"]
let str = ""


numofvowels = 0

function countVowels(str) {
for (i = 0; i < vowels.length; i++)
if (vowels.includes(str[i])) {
numofvowels++
}

return numofvowels

}



console.log(countVowels("Tested"))


/************************************************************** Stretch **************************************************************/
Expand Down