Skip to content

Jayveon patrick #321

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
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
163 changes: 119 additions & 44 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,25 @@ returns a value, that value will be logged to the console. An example of this w
/*
Task 1a - Voting Age (not auto tested)

Do the following:
Do the following:
1. Create a variable called votingAge and assign it a number value
2. Console log true if age is 18 or higher

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

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


/*
Task 1b - Values (not auto tested)

Do the following:
Do the following:
1. Declare two variables and assign them values (good names for these might be firstThing and secondThing)
2. Use a conditional to check the value of the 1st variable versus the value assigned to the 2nd variable
3. Change the value of the 1st variable if the conditional in step 2 is true
Expand All @@ -34,37 +40,50 @@ Do the following:
HINT: no function required
*/

let person = "Jayveon"
let behavior = "bad"

if(behavior === "bad"){
person = "Jacob"
}else{
person = "Jayveon"
}

console.log(person)



/*
Task 1c - Convert Strings to Numbers (not auto tested)

Do the following:
Do the following:
1. Declare a variable with the string type value of "1999"
2. Convert the string value of "1999" to a integer value of 1999
3. Console log the result

HINT: look up the Number method
*/
const party = "1999";
console.log(number(party));




/*
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(num1, num2){
return num1 * num2;
function multiply(a, b){
return a * b;
}

console.log(multiply(9, 10));



/*🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 Task 2 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀*/
Expand All @@ -77,10 +96,10 @@ Do the following:
3. Return the newly calculated age
*/

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

console.log(dogYears(21));


/*🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 Task 3 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀*/
Expand All @@ -97,55 +116,74 @@ HINT: Remember that the order in which we pass in our arguments matters when it

Feeding Requirements:

Adult Dogs 1 year and older
Adult Dogs 1 year and older
up to 5 lbs - 5% of their body weight
6 - 10 lbs - 4% of their body weight
11 - 15 lbs - 3% of their body weight
> 15lbs - 2% of their body weight
6 - 10 lbs - 4% of their body weight
11 - 15 lbs - 3% of their body weight
> 15lbs - 2% of their body weight

Puppies less than 1 year
2 - 4 months 10% of their body weight
4 - 7 months 5% of their body weight
4 - 7 months 5% of their body weight
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
NOTE 2: This is a great time to check the tests to see what it expects, versus what is actually
returned from your function. This is an example of the output to look for on each test point.
NOTE 2: This is a great time to check the tests to see what it expects, versus what is actually
returned from your function. This is an example of the output to look for on each test point.
● hungryDogFunction › Dog is 1 year and is 5lbs or less

expect(received).toBe(expected) // Object.is equality

Expected: 0.2
Received: undefined

21 | describe('hungryDogFunction', ()=>{
21 | describe('hungryDogFunction', ()=>{
22 | it('Dog is 1 year and is 5lbs or less', ()=>{
> 23 | expect(functions.hungryDog(4, 1)).toBe(0.2);
|
^
24 | })
Notice the expected and received, expected is what the test is looking for, and received is what was actually returned from this function. You can also see it's passing in two values, the number 4 and the number 1.

Notice the expected and received, expected is what the test is looking for, and received is what was actually returned from this function. You can also see it's passing in two values, the number 4 and the number 1.
So, on this one test, the weight would be 4 pounds, and the age would be 1 years old. It's expecting your function to return a decimal number of 0.2
*/
*/

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 && weight > 15){
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.10;
}else{
return "please try again";
}
}

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




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

// Rock, Paper, Scissors - Let's play against the computer!
// Rock, Paper, Scissors - Let's play against the computerr!
/*
Do the following:
1. Create a new variable that randomly generates the computer's choice, this must not be done inside the function
2. Use Math.random to determine the computer's choice (Math.random gives a random number between 0 and 1)
3. Make a conditional that changes the variable to "rock", "paper", or "scissors" based on it's random number

Use the game function below to do the following:
1. Receive 2 parameters: a string with the user's choice of "rock", "paper", or "scissors"
1. Receive 2 parameters: a string with the user's choice of "rock", "paper", or "scissors"
and the computer's choice of "rock", "paper", or "scissors".
Note: make sure the strings are all lower case or it will not pass the test
2. Return whether the user won, lost, or tied based on these rules of the game described below - the strings returned need to match these strings below exactly.
Expand All @@ -156,27 +194,46 @@ Use the game function below to do the following:
RULES OF THE GAME: Scissors beats Paper | Paper beats Rock | Rock beats Scissors | Or there's a tie
*/

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

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


function game(user, computer){
if(user === computer){
return "it is a tie"
}else if(user === "rock " && computer === "scissors"){
return "you win"
}else if(user === "paper" && computer === "rock"){
return "you win"
}else{
return "you lose"
}

}

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

//Metric Converter
//Task 5a - Kilometers to Miles
//Metric Converter
//Task 5a - Kilometers 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 - Centimeters to Feet
Expand All @@ -187,10 +244,13 @@ 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(180));




/*🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 Task 6 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀*/
Expand All @@ -203,32 +263,47 @@ Using the annoyingSong function below do the following:

"{number you gave as an argument} bottles of soda on the wall, {number you gave as an argument} bottles of soda, take one down pass it around {number you gave as an argument minus 1} bottles of soda on the wall"

3. Outside of the function, Make a loop that invokes annoying song with a number that decreases until it gets to 1 bottle left.
4. Each time the annoyingSong is run from this loop, it should console.log the string that was returned.
3. Outside of the function, Make a loop that invokes annoying song with a number that decreases until it gets to 1 bottle left.
4. Each time the annoyingSong is run from this loop, it should console.log the string that was returned.
*/

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`;
}


}

console.log(annoyingSong(12));

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

//Grade Calculator
/*
Using the grade function below do the following:
1. Receive a score out of 100
Using the grade function below do the following:
1. Receive a score out of 100
2. Return the corresponding letter grade following this grade scale:

90-100 should return 'you got an A'
90-100 should return 'you got an A'
80-89 should return 'you got a B'
70-79 should return 'you got a C'
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"
}
}


Expand All @@ -241,7 +316,7 @@ Using the vowelCounter function below do the following:
1. Receive a string as a parameter
2. Count and return the number of vowels within that string. It should handle both capitalized and uncapitalized vowels.

HINT - you may need to study tomorrow's content on arrays
HINT - you may need to study tomorrow's content on arrays
HINT - try looking up the .includes() method
*/

Expand Down
Loading