Skip to content

Beckon roeckel #322

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 9 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
172 changes: 141 additions & 31 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,12 @@ Do the following:

HINT: no function required
*/
let votingAge=23;
if (votingAge<=18){
console.log('Task 1:a=', false);
} else{
console.log("Task 1:a=", true);
}



Expand All @@ -33,7 +39,13 @@ Do the following:

HINT: no function required
*/

let thingOne= 12;
let thingTwo=3;
if (thingOne===thingTwo){
console.log('task 1b=', true);
} else {
console.log("task 1b=", false)
}



Expand All @@ -49,8 +61,8 @@ Do the following:
HINT: look up the Number method
*/



const party= '1999';
console.log('task 1c done the right way=', Number(party));

/*
Task 1d - Multiply
Expand All @@ -64,7 +76,7 @@ Do the following:
function multiply(num1, num2){
return num1 * num2;
}

console.log('task 1d=', multiply(12,3));


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

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

console.log('task 2=', dogYears(Math.floor(Math.random()*100)));


/*🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 Task 3 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀*/
Expand All @@ -96,7 +108,6 @@ REMEMBER: This program should handle correctly adult AND puppy ages and weights
HINT: Remember that the order in which we pass in our arguments matters when it comes to parameters

Feeding Requirements:

Adult Dogs 1 year and older
up to 5 lbs - 5% of their body weight
6 - 10 lbs - 4% of their body weight
Expand All @@ -107,8 +118,8 @@ Puppies less than 1 year
2 - 4 months 10% 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: 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.
● hungryDogFunction › Dog is 1 year and is 5lbs or less
Expand All @@ -127,11 +138,57 @@ NOTE 2: This is a great time to check the tests to see what it expects, versus w

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<0.33){
let percent=0.1;
let DFA= weight*percent;
console.log ('task 3=',
"Weight=", weight,
"Age=", age,
"Percent of weight=", percent,
"Lbs of food per day=", DFA);
}
else if (age <=0.58 || age===1 && weight<=5){
let percent=0.05;
let DFA= weight*percent;
console.log ('task 3=',
"Weight=", weight,
"Age=", age,
"Percent of weight=", percent,
"Lbs of food per day=", DFA);
}
else if (age <=1 || age===1 && weight<=10){
let percent=0.04;
let DFA= weight*percent;
console.log ('task 3=',
"Weight=", weight,
"Age=", age,
"Percent of weight=", percent,
"Lbs of food per day=", DFA);
}
else if (age===1 && weight<=15){
let percent=0.03;
let DFA= weight*percent;
console.log ('task 3=',
"Weight=", weight,
"Age=", age,
"Percent of weight=", percent,
"Lbs of food per day=", DFA);
}
else {
let percent= 0.02;
let DFA= weight*percent;
console.log ('task 3=',
"Weight=", weight,
"Age=", age,
"Percent of weight=", percent,
"Lbs of food per day=", DFA);
}
}
hungryDog(Math.ceil(Math.random()*10),(Math.random()*10));





Expand All @@ -153,12 +210,33 @@ Use the game function below to do the following:
- lose should return "you lose!"
- tie should return "it's a tie"

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*/
RULES OF THE GAME: Scissors beats Paper | Paper beats Rock | Rock beats Scissors | Or there's a tie*/

let cInput=Math.floor((Math.random()*3));
console.log(cInput);
if (cInput===0){
cInput= "scissors";
console.log('task 4= computer chooses', cInput);
}else if (cInput===1){
cInput= "paper";
console.log('task 4= computer chooses', cInput);
}else{
cInput= "rock";
console.log('task 4= computer chooses', cInput);
}
function game(pInput,cInput){
if (pInput==="rock" && cInput==="scissors" || pInput==="scissors" && cInput==="paper" || pInput==="paper" && cInput==="rock"){
console.log("task 4= you win!");
return;
}else if (cInput===pInput){
console.log("task 4= its a tie");
return;
}else {
console.log("task 4= you lose!");
return;
}
}
game("scissors",cInput);



Expand All @@ -173,9 +251,11 @@ Using the miles function below do the following:
3. Return the number of miles
*/

function miles(/*add your code here*/){
/*add your code here*/
function miles(kilometers){
console.log('task 5a= '+ kilometers*.621371);
return;
}
miles(Math.ceil(Math.random()*10));



Expand All @@ -187,9 +267,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){
console.log('task 5b= '+cm*0.028084);
return;
}
feet(Math.ceil(Math.random()*10));



Expand All @@ -207,9 +289,13 @@ Using the annoyingSong function below do the following:
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(bottles){
for (var i=bottles; i>0; i--){
console.log(bottles+" bottles of soda on the wall, "+bottles+" bottles of soda, take one down pass it around, "+(bottles-1)+" of soda on the wall.");
var bottles=bottles-1;
}
}
annoyingSong(Math.ceil(Math.random()*10));


/*🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 Task 7 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀*/
Expand All @@ -227,9 +313,26 @@ Using the grade function below do the following:
below should return 'you got an F'
*/

function grade(/*Your Code here */){
/*Your Code here */
function grade(gradeNumber){
if (gradeNumber>89){
console.log('task 7= ', gradeNumber, "You got an A!");
return;
} else if (gradeNumber>79){
console.log('task 7= ', gradeNumber, "You got a B!");
return;
} else if (gradeNumber>69){
console.log('task 7= ', gradeNumber, "You got a C!");
return;
} else if (gradeNumber>59){
console.log('task 7= ', gradeNumber, "You got a D!");
return;
} else {
console.log('task 7= ', gradeNumber, "You got a F!");
return;
}
}
grade(Math.floor(Math.random()*100));




Expand All @@ -245,16 +348,23 @@ HINT - you may need to study tomorrow's content on arrays
HINT - try looking up the .includes() method
*/


function vowelCounter(/*add your code here*/) {
/*add your code here*/
function vowelCounter(str){
let getCount=0;
const vowels= ['a','e','i','o','u'];
for (let char of str){
if (vowels.includes(char)){
getCount++;
}
}
return getCount;
}
console.log("There are",vowelCounter("its working"), "vowels in this sentence.");



/*🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑 Please do not modify anything below this line 🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑*/
function foo(){
console.log('its working');
console.log('final check= its working');
return 'bar';
}
foo();
Expand Down
Loading