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: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
<title>Document</title>
</head>
<body>
<script src="index.js"></script>
</body>
<script type="text/javascript" src="js/index.js" ></script>
</html>
135 changes: 120 additions & 15 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ 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;
// }



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

function dogYears(/*add your code here*/){
/*add your code here*/
function dogYears(humanYears, dogAge){
let dogAge = humanYears * 7;
return dogAge;
}


Expand Down Expand Up @@ -106,11 +107,39 @@ 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*/){
function hungryDog(dogAge, dogWeight){
/*add your code here*/
if(dogAge >= 12 && dogWeight <= 5){
let foodAmount = dogWeight * .05;
return 'This dog should eat ' + foodAmount + ' lbs. of food.';
}else if(dogAge >= 12 && dogWeight >= 6 && dogWeight <= 10){
let foodAmount = dogWeight * .04;
return 'This do should eat ' + foodAmount + ' lbs. of food.';
}else if(dogAge >= 12 && dogWeight >= 11 && dogWeight <= 15){
let foodAmount = dogWeight * .03;
return 'This do should eat ' + foodAmount + ' lbs. of food.';
}else if(dogAge >= 12 && dogWeight > 15){
let foodAmount = dogWeight * .02;
return 'This do should eat ' + foodAmount + ' lbs. of food.';
}else if(dogAge = 12 && dogWeight >= 6 || dogWeight <= 10){
let foodAmount = dogWeight * .04;
return 'This do should eat ' + foodAmount + ' lbs. of food.';
}else if(dogAge >= 2 && dogAge <= 4){
let foodAmount = dogWeight * .1;
return 'This do should eat ' + foodAmount + ' lbs. of food.';
}else if(dogAge >= 4 && dogAge <= 7){
let foodAmount = dogWeight * .05;
return 'This do should eat ' + foodAmount + ' lbs. of food.';
}else if(dogAge >= 7 && dogAge <= 12){
let foodAmount = dogWeight * .04;
return 'This do should eat ' + foodAmount + ' lbs. of food.';
}

}

hungryDog(dogAge, dogWeight);




/*🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 Task 4 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀*/
Expand All @@ -134,11 +163,58 @@ Use the game function below to do the following:
HINT: Remember that the order in which we pass in our arguments matters when it comes to parameters
*/

function computerMove(){
let computerChoice = [Math.floor(Math.random() * 3)];
if(computerChoice === 0){
return 'rock';
}
if(computerChoice === 1){
return 'paper';
}
return 'scissors';
}

function playerMove(){
let playerChoice = prompt('Type rock, paper, or scissors.');
playersChoice.toLowerCase();
return playerChoice;
}

game(user, computer);

let computer = computerMove();
let user = playerMove();

function game(user, computer){
/*add your code here*/
// /*add your code here*/
if(user === 'rock' && computer === 'rock'){
return 'its a tie';
}
if(user === 'paper' && computer === 'paper'){
return 'its a tie';
}
if(user === 'scissors' && computer === 'rocks'){
return 'its a tie';
}
if(user === 'rock' && computer === 'paper'){
return 'you lose!';
}
if(user === 'rock' && computer === 'scissors'){
return 'you win!';
}
if(user === 'paper' && computer === 'rock'){
return 'you win!';
}
if(user === 'paper' && computer === 'scissors'){
return 'you lose!';
}
if(user === 'scissors' && computer === 'rock'){
return 'you lose!';
}
if(user === 'scissors' && computer === 'paper'){
return 'you win';
}
}



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

Expand All @@ -151,8 +227,13 @@ Using the miles function below do the following:
3. Return the number of miles
*/

function miles(/*add your code here*/){
miles();

function miles(km){
/*add your code here*/
var km = prompt('Type in the kilometers to convert.')
let convMiles = km / 1.609;
return alert('' + km + ' converts to ' + convMiles + ' miles!');
}


Expand All @@ -164,9 +245,13 @@ Using the feet function below do the following:
2. Convert the number of cm to feet
3. Return number of feet
*/
feet();

function feet(/*add your code here*/){
function feet(cm){
/*add your code here*/
var cm = prompt('Type in the centimeters to convert.')
let convCentimeters = cm / 30.48;
return alert('' + cm + ' converts to ' + convCentimeters + ' centimeters!');
}


Expand All @@ -180,9 +265,15 @@ Using the annoyingSong function below do the following:
2. At each invocation, it should RETURN this string (note: the tests are expecting the same string as below):
"{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"
*/
annoyingSong();

function annoyingSong(/*add your code here*/){
function annoyingSong(numberOfSongs){
/*add your code here*/
var numberOfSongs = prompt('How many times to you want to sing the song?');
var song = '' + i + ' bottles of soda on the wall, ' + i + ' bottles of soda, take one down pass it around ' + i-- + ' bottles of soda on the wall'
for(var i = 0; i <= numberOfSongs; i--){
return alert(song);
}
}


Expand All @@ -200,9 +291,23 @@ Using the grade function below do the following:
60-69 should return 'you got a D'
below should return 'you got an F'
*/

function grade(/*Your Code here */){
grade();
function grade(score){
/*Your Code here */
var score = prompt('What is the score?');
if(score >= 90 && score <= 100){
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 an D';
}
return 'You got an F';
}


Expand Down