Skip to content

completed module 2 #318

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 1 commit into
base: main
Choose a base branch
from
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
125 changes: 100 additions & 25 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,12 @@ Do the following:

HINT: no function required
*/


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

/*
Task 1b - Values (not auto tested)
Expand All @@ -33,8 +37,14 @@ Do the following:

HINT: no function required
*/
let computer = 'mac'
let computerAge = 'old'

if(computerAge === 'old'){
computer = 'time for a new one'
}

console.log("task 1 b:", computer)



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


let party = "1999"
console.log("Task 1 c: ", Number(party));


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

console.log("Task 1 d: ", multiply(3,4))


/*🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 Task 2 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀*/
Expand All @@ -77,10 +88,11 @@ 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("Task 2: ", dogYears(1));


/*🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 Task 3 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀*/
Expand Down Expand Up @@ -129,10 +141,25 @@ NOTE 2: This is a great time to check the tests to see what it expects, versus w
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 < 10){
return weight * 0.04;
} else if (age >= 1 && weight < 15){
return weight * 0.03;
} else if (age >= 1 && weight > 15){
return weight * 0.02
} else if (age < 0.333) {
return weight * 0.1;
} else if(age > 0.333 && age < 0.583){
return weight * 0.05;
} else if(age < 1 && age > 0.583){
return weight * 0.04;
}
}

console.log("task 3:", hungryDog(6, 1))


/*🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 Task 4 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀*/
Expand All @@ -156,10 +183,30 @@ 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 computerChoice = Math.random;

function game(user, computerChoice){
if(computerChoice <= 0.34){
computerChoice = 'rock';
}else if(computerChoice <= 0.67){
computerChoice = 'paper';
}else if(computerChoice > 0.67){
computerChoice = 'scissors';
}
if(user === computerChoice){
return "it's a tie";
} else if(user === 'rock' && computerChoice === "scissors"){
return "you win!";
} else if(user === 'paper' && computerChoice === 'rock'){
return 'you win!';
} else if(user === 'scissors' && computerChoice === 'paper'){
return "you win!";
} else {
return "you lose!";
}
}

game('paper', computerChoice);
console.log('taks 4: ', game('paper', computerChoice))


/*🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 Task 5 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀*/
Expand All @@ -173,8 +220,8 @@ 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
}


Expand All @@ -187,8 +234,8 @@ 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
}


Expand All @@ -207,10 +254,14 @@ 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(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("Task 6:", annoyingSong(8))


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

Expand All @@ -227,8 +278,18 @@ 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(score){
if(score < 100 && score >= 90 ){
return 'you got an A'
} else if(score < 90 && score >= 80 ){
return 'you got a B'
} else if(score < 80 && score >= 70 ){
return 'you got a C'
} else if(score < 70 && score >= 60 ){
return 'you got a D'
} else {
return 'you got an F'
}
}


Expand All @@ -246,10 +307,24 @@ HINT - try looking up the .includes() method
*/


function vowelCounter(/*add your code here*/) {
/*add your code here*/
function vowelCounter(sentence) {
j = 0
for(let i = sentence.length - 1; i > 0; i --){
if(i === "a" || "A"){
j ++
} else if(i === "e" || "E"){
j ++
} else if(i === "i" || "I"){
j ++
} else if(i === "o" || "O"){
j ++
} else if(i === "u" || "U"){
j ++
}
}
return j
}

//p.s even the array documentation does not mention .includes() information.


/*🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑 Please do not modify anything below this line 🛑🛑🛑🛑🛑🛑🛑🛑🛑🛑*/
Expand Down