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
179 changes: 113 additions & 66 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
/*🏋️‍♂️🏋️‍♂️🏋️‍♂️🏋️‍♂️🏋️‍♂️🏋️‍♂️🏋️‍♂️🏋️‍♂️🏋️‍♂️ Task 1: Warm-up! 🏋️‍♂️🏋️‍♂️🏋️‍♂️🏋️‍♂️🏋️‍♂️🏋️‍♂️🏋️‍♂️🏋️‍♂️🏋️‍♂️*/

import { TestWatcher } from "@jest/core";

/*MAKE SURE TO RETURN ALL OF THE ANSWERS INSIDE OF A FUNCTION ON THESE TASKS, IF YOU DON'T, THE AUTOGRADER WILL NOT WORK*/

/*
Expand All @@ -17,24 +19,30 @@ Do the following:

HINT: no function required
*/
const votingAge = 50;


if (votingAge >= 18) {
console.log(true);
}

/*
Task 1b - Values

Do the following:
Do the following:
1. Declare two variables and assign them values
2. Use a conditional to change the value of the 1st variable based on the value assigned to the 2nd variable
3. Console log the new value of the 1st variable

HINT: no function required
*/

let myName = "bri";
let favColor = "blue";




if (favColor === "blue") {
myName = "Kate";
console.log(myName);
}
/*
Task 1c - Convert Strings to Numbers

Expand All @@ -43,26 +51,26 @@ Do the following:
2. Convert the string value of "1999" to a integer value of 1999
3. Console log the result

HINT: look up the Number method
HINT: look up the Number methods
*/



const stringValue = "1999";
const numberValue = Number(stringValue);
console.log(numberValue);

/*
Task 1d - Multiply

Do the following:
Do the following:
1. Invoke the multiply function below and pass it two numbers
2. Receive the parameters: a and b
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;
}
// multiply(5, 5);

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

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

function dogYears(/*add your code here*/){
/*add your code here*/
function dogYears(age) {
let yourDog = age * 7;
return yourDog;
}


// dogYears(14);

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

Expand All @@ -105,13 +113,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.5;
} else if (age >= 1 && weight >= 66 && weight <= 10) {
return weight * 0.04;
} else if (age >= 1 && weight >= 11 && weight <= 15) {
return weight * 0.03;
} else if (age >= 1 && weight > 15) {
return weight * 0.02;
} else if (age < 1 && age >= 0.583) {
return weight * 0.04;
} else if (age < 0.538 && 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 +158,49 @@ 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 randNum = Math.random();
let computerChoice =
randNum < 0.33
? "rock"
: randNum >= 0.33 && randNum < 0.66
? "paper"
: "scissors";

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

/*add your code here*/
}



/*🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 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) {
let miles = kilometers * 0.621371;
return miles;
}

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

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


// let cm = 235;
// let cm = ft / 0.032808;
// ft = cm * 0.032808;
function feet(centimeters) {
const feet = centimeters / 30.48;
return feet;
}

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

Expand All @@ -181,10 +228,11 @@ 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(startingNumber) {
return `${startingNumber} bottles of soda on the wall, ${startingNumber} bottles of soda, take one down pass it around ${
startingNumber - 1
} bottles of soda on the wall`;
}

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

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

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

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