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
23 changes: 23 additions & 0 deletions demo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
// Let's Sing 99 Bottles of Soda on the Wall!
/*
Using the annoyingSong function below do the following:
1. Receive a starting number and start the count down from the number received
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"
*/

function annoyingSong(i){
var bottlesLeft = i - 1
text = ""
text1 = " bottles of soda on the wall, "
text2 = " bottles of soda, take one down pass it around "
text3 = " bottles of soda on the wall"
text4 = "\n"

while (i > 0) {
text += i + text1 + i + text2 + bottlesLeft + text3 + text4;
i--;
}
return text;
}
console.log(annoyingSong(4));
183 changes: 151 additions & 32 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,16 @@ Do the following:
HINT: no function required
*/

var votingAge = 32;

if (votingAge >= 18)
{ console.log('True');

}
else {
console.log ('False');
}



/*
Expand All @@ -31,7 +41,13 @@ Do the following:
HINT: no function required
*/

var varOne = 55;
var varTwo = 99;

if (varTwo > 95)
{ varOne = 65;
console.log(varOne)
}



Expand All @@ -45,8 +61,9 @@ Do the following:

HINT: look up the Number method
*/


var strDate = "1999"
var b = parseInt(strDate)
console.log(b);


/*
Expand All @@ -58,10 +75,14 @@ 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(2,6));



/*🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 Task 2 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀*/
Expand All @@ -74,10 +95,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(32));


/*🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 Task 3 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀*/
Expand Down Expand Up @@ -107,11 +130,43 @@ 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*/
}


function hungryDog(weight, age)
{
if (age >=1)
{
if (weight <= 5) {
return weight *.05;
}
else if (weight >=10 && weight <= 10) {
return weight * .04;
}
else if (weight >=11 && weight <= 15){
return weight * 0.03;
}
else {
return weight * .02;
}
}
else if (age < 1)
{
if (age >= (2/12) && age < (4/12)) {
return weight * .1;
}
else if (age >= (4/12) && age < (7/12)) {
return weight * .05;
}
else if (age >= (7/12) && age < (12/12)) {
return weight * .04;
}


}

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


/*🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 Task 4 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀*/

Expand All @@ -134,9 +189,47 @@ 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
*/

var computer = Math.random()

function game(user, computer){
/*add your code here*/
}
var rock = .33
var paper = .66
var scissors = .67
var user = scissors


if (user = "rock")
{
if (computer >= .34 && computer <= .67){
return "you lose!";
}
if (computer >.66) {
return "you win!";
}
else return "it's a tie!";
}
if (user = "paper"){
if (computer < .34){
return "you win!";
}
else if (computer > .66){
return "you lose!";
}
else return "it's a tie!";
}

if (user = "scissors"){
if (computer < .34){
return "you lose!";
}
if (computer > .66){
return "it's a tie!";
}
else return "you win!"
}
}
console.log(game("rock",computer));




Expand All @@ -151,10 +244,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 / 1.6;
}

console.log(miles());


//Task 5b - Feet to CM
Expand All @@ -165,25 +259,37 @@ 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;
}

console.log(feet());


/*🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 Task 6 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀*/

// Let's Sing 99 Bottles of Soda on the Wall!
/*
Using the annoyingSong function below do the following:
1. Receive a starting number and start the count down from the number received
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"
*/

function annoyingSong(/*add your code here*/){
/*add your code here*/
function annoyingSong(i){
var bottlesLeft = i - 1
text = ""
text1 = " bottles of soda on the wall, "
text2 = " bottles of soda, take one down pass it around "
text3 = " bottles of soda on the wall"
text4 = "\n"

while (i > 0) {
text += i + text1 + i + text2 + bottlesLeft + text3 + text4;
i--;
}
return text;
}
console.log(annoyingSong(4));








/*🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀 Task 7 🚀🚀🚀🚀🚀🚀🚀🚀🚀🚀*/
Expand All @@ -201,11 +307,24 @@ 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 >=90) {
return "you got an A";
}


else if (score >= 80 && score <= 89) {
return "you got a B"
}
else if (score >= 70 && score <= 79){
return "you got a C"
}
else if (score >= 60 && score <= 69){
return "you got a D"
}
else return "you got an F";
}
console.log(grade());

/*💪💪💪💪💪💪💪💪💪💪 Stretch 💪💪💪💪💪💪💪💪💪💪*/

Expand Down