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
14 changes: 7 additions & 7 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Document</title>
</head>
<body>
</head>
<body>
<script src="index.js"></script>
</body>
</html>
</body>
</html>
167 changes: 112 additions & 55 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@ Do the following:
HINT: no function required
*/


const votingAge = 21;
if (votingAge >= 18) {
console.log("task 1a", true);
} else {
console.log(false);
}

/*
Task 1b - Values
Expand All @@ -31,9 +36,14 @@ Do the following:
HINT: no function required
*/

let variable1 = 20;
let variable2 = 27;

if (variable2 > 22) {
variable1 = variable2 + 1;
}


console.log("task 1b", variable1);

/*
Task 1c - Convert Strings to Numbers
Expand All @@ -46,8 +56,13 @@ Do the following:
HINT: look up the Number method
*/

// const stringNum = "1999";
// parseInt(stringNum);

// console.log("task 1c", stringNum);

const party = "1999";
console.log("task 1c", Number(party));

/*
Task 1d - Multiply
Expand All @@ -58,11 +73,10 @@ Do the following:
3. Multiply a and b and return the answer
*/

function multiply(/*add your code here*/){
/*add your code here*/
}


function multiply(a, b) {
return a * b;
}
console.log("task 1d", multiply(3, 4));

/*🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 Task 2 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀*/

Expand All @@ -74,12 +88,11 @@ Do the following:
3. Return the newly calculated age
*/

function dogYears(/*add your code here*/){
/*add your code here*/
function dogYears(dogAge) {
var humAge = 7 * dogAge;
return humAge;
}



/*🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 Task 3 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀*/

//Dog feeder - Depending on their weight and age, we need to know how many pounds of food to feed our dog each day!
Expand All @@ -105,13 +118,29 @@ Use the hungryDog function and feeding requirements below to do the following:
7 - 12 months 4% of their body weight

NOTE: If done correctly, a weight of 15 lbs and age of 1 year would return 0.44999999999999996
*/
*/

function hungryDog(/*add your code here*/){
/*add your code here*/
function hungryDog(weight, age) {
if (age >= 1 && weight <= 5) {
return weight * 0.05;
} else if (age >= 1 && weight >= 6 && weight <= 10) {
return weight * 0.04;
} else if (age >= 1 && weight >= 11 && weight <= 15) {
return weight * 0.03;
} else if (age < 1 && age >= 0.583) {
return weight * 0.02;
} else if (age < 1 && age >= 0.583) {
return weight + 0.04;
} else if (age < 0.583 && age >= 0.333) {
return weight * 0.05;
} else if (age < 0.333) {
return weight * 0.1;
} else {
return "please try again";
}
}


console.log("Task 3", hungryDog(15, 1));

/*🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 Task 4 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀*/

Expand All @@ -134,28 +163,48 @@ Use the game function below to do the following:
HINT: Remember that the order in which we pass in our arguments matters when it comes to parameters
*/

function game(user, computer){
/*add your code here*/
let computer = Math.random();

if (computer <= 0.34) {
computer = `rock`;
} else if (computer <= 0.67) {
computer = `paper`;
} else if (computer > 0.67) {
computer = `scissors`;
}

function game(user, computer) {
if (user === computer) {
return `it's a tie`;
} else if (user === `rock` && computer === `scissors`) {
return `you win!`;
} else if (user === `paper` && computer === `rock`) {
return `you win!`;
} else if (user === `scissors` && computer === `paper`) {
return `you win!`;
} else {
return `you lose!`;
}
}

console.log(game(`Paper`, computer));

/*🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 Task 5 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀*/

//Metric Converter
//Task 5a - KM to Miles
//Metric Converter
//Task 5a - KM to Miles
/*
Using the miles function below do the following:
1. Receive a number of kilometers
2. Convert the number of kiolmeters received to miles
3. Return the number of miles
*/

function miles(/*add your code here*/){
/*add your code here*/
}

function miles(km) {
return km * 0.621371;
}

console.log(miles(2));

//Task 5b - Feet to CM
/*
Expand All @@ -165,11 +214,11 @@ Using the feet function below do the following:
3. Return number of feet
*/

function feet(/*add your code here*/){
/*add your code here*/
}

function feet(cm) {
return cm / 30.48;
}

console.log(feet(160));

/*🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 Task 6 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀*/

Expand All @@ -181,10 +230,13 @@ Using the annoyingSong function below do the following:
"{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(/*add your code here*/){
/*add your code here*/
function annoyingSong(number) {
for (let i = number; i > 0; i--) {
return `${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`;
}

}

/*🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 Task 7 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀*/

Expand All @@ -200,12 +252,20 @@ Using the grade function below do the following:
60-69 should return 'you got a D'
below should return 'you got an F'
*/

function grade(/*Your Code here */){
/*Your Code here */

function grade(number) {
if (number >= 90) {
return `you got an A`;
} else if (number < 90 && number >= 80) {
return `you got a B`;
} else if (number < 80 && number >= 70) {
return `you got a C`;
} else if (number < 70 && number >= 60) {
return `you got a D`;
} else if (number < 60) {
return `you got an F`;
}


}

/*💪💪💪💪💪💪💪💪💪💪 Stretch 💪💪💪💪💪💪💪💪💪💪*/

Expand All @@ -219,27 +279,24 @@ Using the vowelCounter function below do the following:
HINT - try looking up the .includes() method
*/


function vowelCounter(/*add your code here*/) {
/*add your code here*/
/*add your code here*/
}



/*🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑 Please do not modify anything below this line 🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑*/
function foo(){
//console.log('its working');
return 'bar';
function foo() {
//console.log('its working');
return "bar";
}
/*🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑 Don't touch the code after this line! 🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑*/
export default{
foo,
multiply,
dogYears,
hungryDog,
game,
miles,
feet,
annoyingSong,
grade
}
export default {
foo,
multiply,
dogYears,
hungryDog,
game,
miles,
feet,
annoyingSong,
grade,
};