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
Binary file added .DS_Store
Binary file not shown.
3 changes: 3 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"liveServer.settings.port": 5502
}
129 changes: 102 additions & 27 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,16 @@ Task 1a - Voting Age
Do the following:
1. Make a variable called votingAge and give it a value
2. Return true if age is 18 or higher
if (age<18) {
over 18 = "true";
under 18 = "false";
}
HINT: no function required*/

HINT: no function required
*/
const votingAge = 18;
if (votingAge >= 18) {
console.log('true');
}



Expand All @@ -30,8 +37,12 @@ Do the following:

HINT: no function required
*/


let num1 = 14;
let num2 = 1;
if (num1 > num2 ){
num1= num1 + num2;
}
console.log(num1);



Expand All @@ -45,7 +56,9 @@ Do the following:

HINT: look up the Number method
*/

let year = "1999"
Number(year);
console.log(year);



Expand All @@ -58,11 +71,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(multiply(5,4));

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

Expand All @@ -74,9 +86,10 @@ Do the following:
3. Return the newly calculated age
*/

function dogYears(/*add your code here*/){
/*add your code here*/
function dogYears(humanAge){
return humanAge * 7;
}
console.log(dogYears(2))



Expand Down Expand Up @@ -106,10 +119,34 @@ Use the hungryDog function and feeding requirements below to do the following:

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*/
//test// hasdhaalsdh
function hungryDog(weight,age){
if (age < .33){
return weight * 0.1;
}
else if( age > .33 && age < .58){
return weight * .05;
}
else if (age > .58 && age < 1){
return weight * .04;
}
if (age >= 1 && weight <=5){
return weight * .05;
}
else if( age >=1 && weight >=6 && weight <=10){
return weight * .04;
}
else if( age >=1 && weight >=11 && weight <=15){
return weight * .03;
}
else if(age >=1 && weight >15){
return weight * .02;
}

}
console.log(hungryDog(19,4));





Expand All @@ -128,11 +165,30 @@ Use the game function below to do the following:

HINT: While you can complete this with only conditionals based on strings, it may help to equate choice to a number when using Math.random()
*/
let computerChoice = Math.floor(Math.random() * 3 + 1);
function game(userChoice, computerChoice){

if (computerChoice === 1){
computerChoice = 'rock';
}
else if (computerChoice === 2){
computerChoice = 'paper';
}
else if (computerChoice === 3){
computerChoice = 'scissors';
}

if (userChoice === computerChoice ){
return "it's a tie";
}
else if ( userChoice === 'rock' && computerChoice === 'paper' || userChoice === 'paper' && computerChoice === 'sissors' || userChoice === 'sissors' && computerChoice === 'rock') {
return "you lose!";
} else {
return "you win!";
}

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

console.log(game('rock',computerChoice));


/*🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 Task 5 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀*/
Expand All @@ -146,10 +202,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){
return kilometers * 0.621371;
}

console.log(miles(5));



//Task 5b - Feet to CM
Expand All @@ -160,10 +217,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(centimeters){
return centimeters / 30.48;
}

console.log(feet(15));


/*🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 Task 6 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀*/
Expand All @@ -176,9 +234,12 @@ 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(numberofBottles){
while (numberofBottles > 0){
return `${numberofBottles} bottles of soda on the wall, ${numberofBottles} bottles of soda, take one down pass it around ${numberofBottles-1} bottles of soda on the wall`;
}
}
console.log(annoyingSong(4));


/*🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 Task 7 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀*/
Expand All @@ -196,9 +257,23 @@ Using the grade function below do the following:
below 60 = F
*/

function grade(/*add your code here*/){
/*add your code here*/
function grade(score){
if (score >=90) {
return 'you got an A';
}
if (score >=80 && score <=89){
return 'you got a B';
}
if (score >=70 && score <=79){
return 'you got a C';
}
if (score >=60 && score <=69){
return 'you got a D';
}
if (score <59){
return 'you got an F';
}
}



Expand Down
Loading