Skip to content
Open
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
201 changes: 135 additions & 66 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,12 @@ Do the following:

HINT: no function required
*/


let votingAge = 21;
if (votingAge >= 18) {
console.log(true);
} else {
console.log(false);
}

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

let firstVariable = 1;
const secondVariable = 2;



if (secondVariable === 2) {
firstVariable += secondVariable;
console.log(firstVariable);
}

/*
Task 1c - Convert Strings to Numbers
Expand All @@ -45,10 +53,9 @@ Do the following:

HINT: look up the Number method
*/




let strVariable = "1999";
let numVariable = Number(strVariable);
console.log(numVariable);
/*
Task 1d - Multiply

Expand All @@ -57,12 +64,15 @@ Do the following:
2. Receive the numbers in the parameters: a and b
3. Multiply a and b and return the answer
*/

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


const a = 2;
const b = 2;
function multiply(a, b) {
let c;
c = a * b;
console.log(c);
return c;
}
multiply(a, b);

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

Expand All @@ -73,12 +83,13 @@ Do the following:
2. Use the received value to calculate the age in dog years (1 human year is equal to 7 dog years)
3. Return the newly calculated age
*/

function dogYears(/*add your code here*/){
/*add your code here*/
const humanYears = 27;
function dogYears(humanYears) {
let dogYears = humanYears * 7;
return dogYears;
}


console.log(dogYears(humanYears));

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

Expand All @@ -105,13 +116,36 @@ 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) {
if (weight <= 5) {
let foodLbs = weight * 0.05;
return foodLbs;
} else if (weight <= 10) {
let foodLbs = weight * 0.04;
return foodLbs;
} else if (weight <= 15) {
let foodLbs = weight * 0.03;
return foodLbs;
} else {
let foodLbs = weight * 0.02;
return foodLbs;
}
} else if (age < 1) {
if (age < 0.33) {
let foodLbs = weight * 0.1;
return foodLbs;
} else if (age < 0.58333) {
let foodLbs = weight * 0.05;
return foodLbs;
} else {
let foodLbs = weight * 0.04;
return foodLbs;
}
}


}

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

Expand All @@ -133,29 +167,55 @@ 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 computerGuess() {
let randomNumber = Math.random();
let computerGuess;
if (randomNumber < 0.33) {
computerGuess = "Paper";
} else if (randomNumber > 0.66) {
computerGuess = "Rock";
} else {
computerGuess = "Scissors";
}
}

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

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

// console.log(game(user, 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(kilometers) {
return kilometers * 0.621371;
}

//Task 5b - Feet to CM
/*
Expand All @@ -165,11 +225,9 @@ 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;
}

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

Expand All @@ -181,10 +239,16 @@ 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) {
return (
number +
" bottles of soda on the wall, " +
number +
" bottles of soda, take one down pass it around " +
(number - 1) +
" bottles of soda on the wall"
);
}

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

Expand All @@ -200,12 +264,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(score) {
if (score >= 90) {
return "you got an A";
} else if (score >= 80) {
return "you got a B";
} else if (score >= 70) {
return "you got a C";
} else if (score >= 60) {
return "you got a D";
} else {
return "you got an F";
}


}

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

Expand All @@ -219,27 +291,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,
};