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
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,5 @@ Please submit your project via codegrade by following [these instructions](https

🧮 [Polya's 4 Step Approach to Problem Solving](http://web.mnstate.edu/peil/M110/Worksheet/PolyaProblemSolve.pdf)


Mary Angelique A. Abacajan
162 changes: 142 additions & 20 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/*🏋️‍♂️🏋️‍♂️🏋️‍♂️🏋️‍♂️🏋️‍♂️🏋️‍♂️🏋️‍♂️🏋️‍♂️🏋️‍♂️ Task 1: Warm-up! 🏋️‍♂️🏋️‍♂️🏋️‍♂️🏋️‍♂️🏋️‍♂️🏋️‍♂️🏋️‍♂️🏋️‍♂️🏋️‍♂️*/

/*MAKE SURE TO RETURN ALL OF THE ANSWERS INSIDE OF A FUNCTION (tasks 1d through task 7), IF YOU DON'T, THE AUTOGRADER WILL NOT WORK*/
/*MAKE SURE TO RETURN ALL OF THE ANSWERS INSIDE OF A FUNCTION (tasks 1d through task 7), IF YOU DON'T, THE AUTO-GRADED WILL NOT WORK*/

// task 1a, 1b, and 1c are not autograded
// task 1a, 1b, and 1c are not auto-graded

/*
When doing these tasks, we recommend using console.log to test the output of your code to make sure it works correctly.
Expand All @@ -20,6 +20,18 @@ Do the following:
HINT: no function required
*/

let votingAge = 18;

if (votingAge >= 18) {
console.log("Is a Voter");

} else {

if (votingAge < 18) {
console.log("Not a Voter")
}
}



/*
Expand All @@ -33,7 +45,14 @@ Do the following:
HINT: no function required
*/

let sport = 'badminton';
const sport2 = 'volleyball';

if (sport2 === "volleyball") {
sport = 'tennis';
}

console.log(sport);



Expand All @@ -48,6 +67,17 @@ Do the following:
HINT: look up the Number method
*/

// let val;

// val = Number("1999");

// console.log(val)

let go = "1999";

go = Number("1999");

console.log(go);



Expand All @@ -60,8 +90,11 @@ Do the following:
3. Multiply a and b and return the answer
*/

function multiply(/*add your code here*/){
/*add your code here*/
let a = 2;
let b = 4;

function multiply(a, b){
return a * b;
}


Expand All @@ -76,10 +109,12 @@ 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(10));



/*🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 Task 3 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀*/
Expand Down Expand Up @@ -109,10 +144,32 @@ Puppies less than 1 year
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.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 < 0.583 && age >= 0.583) {
return weight * 0.04;

} else if (age <= 0.583 && age >= 0.333) {
return weight * 0.05;

} else if (age < 1) {
return weight * 2;
}
}

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



/*🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 Task 4 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀*/
Expand All @@ -136,10 +193,40 @@ RULES OF THE GAME: Scissors beats Paper | Paper beats Rock | Rock beats Scissors
HINT: Remember that the order in which we pass in our arguments matters when it comes to parameters
*/

// Used Math.Radom() and used random numbers from 0 to 1 to divide those random number and assigned them to rock, paper, scissors
let computer = Math.random();

function game(user, computer){
/*add your code here*/
if (computer <= 0.42) {
computer = 'rock';

} else if (computer <= 0.22) {
computer = 'paper';

} else if (computer > 0.36) {
computer = 'scissors';
}

function game(user, computer) {
if(user === computer) {
return `It's a tie`;

} else if (user === 'rock' && computer === 'scissors') {
console.log("You Win!");

}else if (user === 'paper' && computer === 'rock') {
console.log("You Win!");

}else if (user === 'scissors' && computer === 'paper') {
console.log("You Win!");

} else {
console.log("You Lose!")
}
}
}

console.log('task 4', game('rock', computer));


/*🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 Task 5 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀*/
Expand All @@ -149,14 +236,18 @@ function game(user, computer){
/*
Using the miles function below do the following:
1. Receive a number of kilometers
2. Convert the number of kiolmeters received to miles
2. Convert the number of kilometers received to miles
3. Return the number of miles
*/

function miles(/*add your code here*/){
/*add your code here*/
let km = 10;

function miles(km){
return km * 1.60934;
}

console.log(miles());



//Task 5b - Feet to CM
Expand All @@ -167,8 +258,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(cm){
return cm / 30.48
}


Expand All @@ -183,10 +274,15 @@ 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(number){
return (number) +
"{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"
}

console.log(annoyingSong(99));


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

Expand All @@ -203,10 +299,28 @@ Using the grade function below do the following:
below should return 'you got an F'
*/

function grade(/*Your Code here */){
/*Your Code here */
let score = '100';

function grade(score){
if(score >= 90) {
return "You Got an A";

} else if (score >= 80 && score < 90) {
console.log("You got a B");

} else if (score >= 70 && score < 80) {
console.log("You got a C");

} else if (score >= 60 && score < 70) {
console.log("You got a D");

} else if (score < 60) {
console.log("You got an F");
}
}

console.log(score(90));



/*💪💪💪💪💪💪💪💪💪💪 Stretch 💪💪💪💪💪💪💪💪💪💪*/
Expand All @@ -221,9 +335,17 @@ HINT - you may need to study tomorrow's content on arrays
HINT - try looking up the .includes() method
*/

const vowels = ['A', 'a', 'E', 'e', 'I', 'i', 'O', 'o', 'U', 'u'];
function vowelCounter(vowels) {
let vowelsNum = 0;

for(let letter of text) {
if(vowels .includes(letter)) {
vowelsNum++;
}
}

function vowelCounter(/*add your code here*/) {
/*add your code here*/
console.log(vowels);
}


Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.