From 7f272185ac030de413b7551463b7987c20c3947a Mon Sep 17 00:00:00 2001 From: andres ballares Date: Mon, 7 Dec 2020 21:25:22 -0500 Subject: [PATCH 01/15] problem 1 --- problems/variables.js | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/problems/variables.js b/problems/variables.js index 831a97c..1527072 100644 --- a/problems/variables.js +++ b/problems/variables.js @@ -7,6 +7,17 @@ // * For example, if you were born in 1988, then in 2026 you'll be either 37 or 38, depending on what month it is in 2026. // * Log them to the screen like so: "I will be either `ageMin` or `ageMax` in `futureYear`", substituting the values. +let birthYear = '1977' +let futureYear = '2021' +let minimumAge = '44' +let maximumAge = '45' +console.log("I will be either " + minimumAge + " or " + maximumAge + " in " + futureYear) + + + + + + // ## Problem Two // Snack Supply Calculator: From bef3f65ed35eeaa83ff5e79719e74bb5834521a7 Mon Sep 17 00:00:00 2001 From: Cari Date: Mon, 7 Dec 2020 21:39:02 -0500 Subject: [PATCH 02/15] Added problem 2 --- problems/variables.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/problems/variables.js b/problems/variables.js index 1527072..66ab53c 100644 --- a/problems/variables.js +++ b/problems/variables.js @@ -27,8 +27,13 @@ console.log("I will be either " + minimumAge + " or " + maximumAge + " i // * Calculate how many snacks you would eat total, from your current age until the maximum age. // * Log the result to the screen like this: "You will need `snackNumber` to last you until the age of `maxAge`". -// ## Problem Three +let curAge = "30" +const maxAge = "99" +let snackCount = "3" +let snackNumber = ((maxAge - curAge)*(snackCount * 365)) +console.log("You will need "+snackNumber+ " to last you until the age of "+maxAge) +// ## Problem Three // Calculate properties of a circle, using the definitions: http://math2.org/math/geometry/circles.htm // * Store a radius into a variable. // * Calculate the circumference based on the radius, and log "The circumference is `circumferenceResult`". From 2f4b7decbec0b717f12a6818be308e0358bb6410 Mon Sep 17 00:00:00 2001 From: andres ballares Date: Mon, 7 Dec 2020 21:53:23 -0500 Subject: [PATCH 03/15] nothing happen --- problems/variables.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/problems/variables.js b/problems/variables.js index 1527072..ce7abaa 100644 --- a/problems/variables.js +++ b/problems/variables.js @@ -27,6 +27,8 @@ console.log("I will be either " + minimumAge + " or " + maximumAge + " i // * Calculate how many snacks you would eat total, from your current age until the maximum age. // * Log the result to the screen like this: "You will need `snackNumber` to last you until the age of `maxAge`". + + // ## Problem Three // Calculate properties of a circle, using the definitions: http://math2.org/math/geometry/circles.htm @@ -35,6 +37,8 @@ console.log("I will be either " + minimumAge + " or " + maximumAge + " i // * Calculate the area based on the radius, and log "The area is `areaOfCircle`". // * Hint: https://www.w3schools.com/jsref/jsref_pi.asp +gi + // ## Problem Four // Temperature Converter: From d52e9da649fe630c6637da7b1c03a052ce752a0e Mon Sep 17 00:00:00 2001 From: Cari Date: Tue, 8 Dec 2020 19:19:23 -0500 Subject: [PATCH 04/15] nothing. --- problems/variables.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/problems/variables.js b/problems/variables.js index 66ab53c..c0cc7f5 100644 --- a/problems/variables.js +++ b/problems/variables.js @@ -40,6 +40,8 @@ console.log("You will need "+snackNumber+ " to last you until the age of "+maxAg // * Calculate the area based on the radius, and log "The area is `areaOfCircle`". // * Hint: https://www.w3schools.com/jsref/jsref_pi.asp +pi * 7 + // ## Problem Four // Temperature Converter: From 7f3b073ce8eef01fb1072be9ab78f3544f5fe5a9 Mon Sep 17 00:00:00 2001 From: andres ballares Date: Tue, 8 Dec 2020 19:49:42 -0500 Subject: [PATCH 05/15] nothing happen --- problems/variables.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/problems/variables.js b/problems/variables.js index b854318..35af0ef 100644 --- a/problems/variables.js +++ b/problems/variables.js @@ -37,8 +37,7 @@ console.log("You will need "+snackNumber+ " snacks to last you, until the age of // * Calculate the area based on the radius, and log "The area is `areaOfCircle`". // * Hint: https://www.w3schools.com/jsref/jsref_pi.asp -let radius = "7" -let circumferenceofcircle = "(pi * radius)" + // ## Problem Four From 37319d2c7763cde981973cfd1778710c4ce3df6c Mon Sep 17 00:00:00 2001 From: Cari Date: Tue, 8 Dec 2020 20:02:49 -0500 Subject: [PATCH 06/15] nada --- problems/variables.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/problems/variables.js b/problems/variables.js index ebd6cf6..8c7e08d 100644 --- a/problems/variables.js +++ b/problems/variables.js @@ -69,6 +69,8 @@ console.log("Same as, if we convert " + fahrenheit + " into celsius, we would // * Find the average grade of all students // * Print out if Dee's grade is higher than the class average +let aliceGrade = "80%" + // ## Problem Six // Find the last number: From f7d568bce590f13b541f12703971708062be17e2 Mon Sep 17 00:00:00 2001 From: andres ballares Date: Tue, 8 Dec 2020 20:34:32 -0500 Subject: [PATCH 07/15] problem 5 --- problems/variables.js | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/problems/variables.js b/problems/variables.js index 9c4b7f9..077470a 100644 --- a/problems/variables.js +++ b/problems/variables.js @@ -37,16 +37,13 @@ console.log("You will need "+snackNumber+ " snacks to last you, until the age of // * Calculate the area based on the radius, and log "The area is `areaOfCircle`". // * Hint: https://www.w3schools.com/jsref/jsref_pi.asp -<<<<<<< HEAD -======= let radius = "2" let circumferenceOfCircle = Math.PI * radius let areaOfCircle = Math.PI * (radius * 2) console.log("The circumference is " +circumferenceOfCircle) console.log("The area is " +areaOfCircle +".") ->>>>>>> 628490bd8fd766b3f82870af974f8f66da509a8c // ## Problem Four // Temperature Converter: @@ -63,6 +60,9 @@ celsius = "1C°" console.log("Same as, if we convert " + fahrenheit + " into celsius, we would get " + celsius+".") + + + // ## Problem Five // Grades Calculator: @@ -74,6 +74,17 @@ console.log("Same as, if we convert " + fahrenheit + " into celsius, we would // * Find the average grade of all students // * Print out if Dee's grade is higher than the class average +let alice = 70 +let bob = 50 +let cam = 30 +let average = (bob + cam + alice) / 3 +console.log(' The averages of all students is ' + average) +let dee = 90 +average = (bob + cam + alice + dee) / 4 +console.log ( ' The new average of the all students is ' + average) +if(dee > average ) console.log("Dees grade is higher than average") + + // ## Problem Six // Find the last number: From 306efd5c3a664aad163d358418f2f361c0dd1d7f Mon Sep 17 00:00:00 2001 From: Cari Date: Tue, 8 Dec 2020 22:07:17 -0500 Subject: [PATCH 08/15] problem 8 --- problems/variables.js | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/problems/variables.js b/problems/variables.js index 3aa2fa0..dba95b2 100644 --- a/problems/variables.js +++ b/problems/variables.js @@ -98,10 +98,6 @@ let a = "584" let output = a[a.length-1] console.log(output) -let name = "Andres" -let lastLetter = name[name.length-1] -console.log(name.length) -console.log(lastLetter) // Hint: // Use the remainder % operator. @@ -130,6 +126,13 @@ console.log(lastLetter) // * alice + x = y * (bob + x) // * Solve for alice +let x = 2; +let y = 4; +let bobA = 12 +let aliceA = y * (x + bobA)- x +console.log(aliceA) + + // ## Problem Eight // * Cat and Dog Percentages @@ -143,6 +146,13 @@ console.log(lastLetter) // * 25% of the daycare animals are cats // * 75% of the daycare animals are dogs +let numberOfCats = 20 +let numberOfDogs = 60 + +let catPerc = numberOfCats / (numberOfCats + numberOfDogs)*100 +let dogPerc = numberOfDogs / (numberOfCats + numberOfDogs)*100 + +console.log(`The percentage of dogs in the daycare is ${dogPerc}% and the percentage of cats is ${catPerc}%.`) // ## Problem Nine // * Leap Year Calculator From 197dc0d913b1e4591b84e160841685541e64e1f5 Mon Sep 17 00:00:00 2001 From: Cari Date: Tue, 8 Dec 2020 22:11:59 -0500 Subject: [PATCH 09/15] number 10 --- problems/variables.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/problems/variables.js b/problems/variables.js index dba95b2..0972c43 100644 --- a/problems/variables.js +++ b/problems/variables.js @@ -153,6 +153,8 @@ let catPerc = numberOfCats / (numberOfCats + numberOfDogs)*100 let dogPerc = numberOfDogs / (numberOfCats + numberOfDogs)*100 console.log(`The percentage of dogs in the daycare is ${dogPerc}% and the percentage of cats is ${catPerc}%.`) + + // ## Problem Nine // * Leap Year Calculator @@ -165,6 +167,8 @@ console.log(`The percentage of dogs in the daycare is ${dogPerc}% and the percen // * For example 1900 was not a leap year, but 2000 was. Print "Leap year!" or "Not a leap year!" depending on the year you are provided. + + // ## Problem Ten: Predict the output // For this section write what you think will be logged as a comment next to `console.log` like so: `console.log('Cat') //'Cat'` before running the code. Then execute your file and compare with your prediction. @@ -174,14 +178,14 @@ console.log(`The percentage of dogs in the daycare is ${dogPerc}% and the percen // let num1 = 2 // let num2 = 5 // let num3 = num1 * num2 -// console.log(num3) +// console.log(num3)// 10 // ``` // b. // ```js // let str = 'jel' // str += 'lo' -// console.log(str) +// console.log(str) //jello // ``` // c. @@ -189,7 +193,5 @@ console.log(`The percentage of dogs in the daycare is ${dogPerc}% and the percen // let string = 'My favorite number is '; // let number = 42 // let sentence = string + number -// console.log(typeof(sentence)) +// console.log(typeof(sentence))/string // ``` - - From 73e31a2c3456830da4168924e711a2718265fac7 Mon Sep 17 00:00:00 2001 From: Cari Date: Tue, 8 Dec 2020 22:52:25 -0500 Subject: [PATCH 10/15] 9 was rough lol --- problems/variables.js | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/problems/variables.js b/problems/variables.js index 0972c43..629cca2 100644 --- a/problems/variables.js +++ b/problems/variables.js @@ -167,8 +167,20 @@ console.log(`The percentage of dogs in the daycare is ${dogPerc}% and the percen // * For example 1900 was not a leap year, but 2000 was. Print "Leap year!" or "Not a leap year!" depending on the year you are provided. - - +function leapYear(yr) { +if ((yr % 4 == 0 ) && ( yr % 100 != 0)) +{ + console.log("Leap year!")} +else if (yr % 400 == 0) + { + console.log("Leap year!") + } +else +{ + console.log("Not a leap year!") + } +} +console.log(leapYear(2000)) // ## Problem Ten: Predict the output // For this section write what you think will be logged as a comment next to `console.log` like so: `console.log('Cat') //'Cat'` before running the code. Then execute your file and compare with your prediction. From 9d61004f8c177fc3a34feecb7f4c3465f3c701e6 Mon Sep 17 00:00:00 2001 From: Cari Date: Wed, 9 Dec 2020 20:59:47 -0500 Subject: [PATCH 11/15] re-did 1 --- problems/variables.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/problems/variables.js b/problems/variables.js index 629cca2..ae175bf 100644 --- a/problems/variables.js +++ b/problems/variables.js @@ -7,11 +7,13 @@ // * For example, if you were born in 1988, then in 2026 you'll be either 37 or 38, depending on what month it is in 2026. // * Log them to the screen like so: "I will be either `ageMin` or `ageMax` in `futureYear`", substituting the values. -let birthYear = '1977' -let futureYear = '2021' -let minimumAge = '44' -let maximumAge = '45' -console.log("I will be either " + minimumAge + " or " + maximumAge + " in " + futureYear) + const birthYear = 1990 + let futureYear = 2026 + let ageMax = futureYear - birthYear + let ageMin = ageMax - 1 + + console.log(`I will be either ${ageMin} or ${ageMax} in ${futureYear}.`) + // ## Problem Two From cd05eab1f167ccdbc577056d5c23a64a9ac119bf Mon Sep 17 00:00:00 2001 From: Cari Date: Wed, 9 Dec 2020 21:22:34 -0500 Subject: [PATCH 12/15] re-did 3 --- problems/variables.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/problems/variables.js b/problems/variables.js index ae175bf..c3c9bbd 100644 --- a/problems/variables.js +++ b/problems/variables.js @@ -29,7 +29,7 @@ const maxAge = "99" let snackCount = "3" let snackNumber = ((maxAge - curAge)*(snackCount * 365)) -console.log("You will need "+snackNumber+ " snacks to last you, until the age of "+maxAge) +console.log(`You will need ${snackNumber} snacks to last you, until the age of ${maxAge}.`) // ## Problem Three @@ -41,11 +41,10 @@ console.log("You will need "+snackNumber+ " snacks to last you, until the age of -let radius = "2" -let circumferenceOfCircle = Math.PI * radius -let areaOfCircle = Math.PI * (radius * 2) -console.log("The circumference is " +circumferenceOfCircle) -console.log("The area is " +areaOfCircle +".") +let radius = 7 +let areaOfCircle = radius * radius * Math.PI +let circumferenceOfCircle = Math.PI * radius * 2 +console.log(`The circumference is ${circumferenceOfCircle} and the area is ${areaOfCircle}.`) // ## Problem Four // Temperature Converter: From 3b44b7313a33abd77b3060bbdbdc3e68012058f1 Mon Sep 17 00:00:00 2001 From: Cari Date: Wed, 9 Dec 2020 22:10:49 -0500 Subject: [PATCH 13/15] re-did 3 --- problems/variables.js | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/problems/variables.js b/problems/variables.js index c3c9bbd..0aac03d 100644 --- a/problems/variables.js +++ b/problems/variables.js @@ -53,15 +53,13 @@ console.log(`The circumference is ${circumferenceOfCircle} and the area is ${are // * Now store a fahrenheit temperature into a variable. // * Convert it to celsius and output "`tempInFahrenheit`°F is `tempInCelsius`°C." -let celsius = "23C°" -let fahrenheit = "73F°" -console.log("if we were to convert " + celsius + " to Fahrenheit, we would get " + fahrenheit+".") -fahrenheit = "34F°" -celsius = "1C°" -console.log("Same as, if we convert " + fahrenheit + " into celsius, we would get " + celsius+".") - - +let celsius = 23 +let cToF = celsius * 1.8 + 32 +let fahrenheit = 56 +let fToC = (fahrenheit - 32) / 1.8 +console.log(`${celsius}° C is ${cToF}° F`); +console.log(`${fahrenheit}° F is ${fToC}° C`) // ## Problem Five From 5c644a5560a03fb74cbca892cb331e2172304536 Mon Sep 17 00:00:00 2001 From: Cari Date: Wed, 9 Dec 2020 22:39:09 -0500 Subject: [PATCH 14/15] done pt 2 --- problems/variables.js | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/problems/variables.js b/problems/variables.js index 0aac03d..aaa562a 100644 --- a/problems/variables.js +++ b/problems/variables.js @@ -76,12 +76,12 @@ console.log(`${fahrenheit}° F is ${fToC}° C`) let alice = 70 let bob = 50 let cam = 30 -let average = (bob + cam + alice) / 3 -console.log(' The averages of all students is ' + average) -let dee = 90 -average = (bob + cam + alice + dee) / 4 -console.log ( ' The new average of the all students is ' + average) -if(dee > average ) console.log("Dees grade is higher than average") +let average = ((bob + cam + alice) / 3) +let dee = 90 +average = ((bob + cam + alice + dee) / 4) + +if(dee > average ) console.log(`Dees grade is higher than average`) + // ## Problem Six @@ -93,9 +93,10 @@ if(dee > average ) console.log("Dees grade is higher than average") // * Output: // * 3 -let a = "584" -let output = a[a.length-1] -console.log(output) +let a = 6790 +let output = a % 10 + +console.log(`The last digit of ${a} is ${output}.`) // Hint: // Use the remainder % operator. @@ -148,8 +149,8 @@ console.log(aliceA) let numberOfCats = 20 let numberOfDogs = 60 -let catPerc = numberOfCats / (numberOfCats + numberOfDogs)*100 -let dogPerc = numberOfDogs / (numberOfCats + numberOfDogs)*100 +let catPerc = (numberOfCats / (numberOfCats + numberOfDogs))*100 +let dogPerc = (numberOfDogs / (numberOfCats + numberOfDogs))*100 console.log(`The percentage of dogs in the daycare is ${dogPerc}% and the percentage of cats is ${catPerc}%.`) From aefcd20ada2b9274987b3ce5293fb62e94b60681 Mon Sep 17 00:00:00 2001 From: Cari Date: Wed, 9 Dec 2020 22:43:42 -0500 Subject: [PATCH 15/15] () --- problems/variables.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/problems/variables.js b/problems/variables.js index aaa562a..117414f 100644 --- a/problems/variables.js +++ b/problems/variables.js @@ -42,8 +42,8 @@ console.log(`You will need ${snackNumber} snacks to last you, until the age of $ let radius = 7 -let areaOfCircle = radius * radius * Math.PI -let circumferenceOfCircle = Math.PI * radius * 2 +let areaOfCircle = (radius * radius * Math.PI) +let circumferenceOfCircle = (Math.PI * radius * 2) console.log(`The circumference is ${circumferenceOfCircle} and the area is ${areaOfCircle}.`) // ## Problem Four @@ -54,12 +54,12 @@ console.log(`The circumference is ${circumferenceOfCircle} and the area is ${are // * Convert it to celsius and output "`tempInFahrenheit`°F is `tempInCelsius`°C." let celsius = 23 -let cToF = celsius * 1.8 + 32 +let cToF = (celsius * 1.8 + 32) let fahrenheit = 56 -let fToC = (fahrenheit - 32) / 1.8 +let fToC = ((fahrenheit - 32) / 1.8) console.log(`${celsius}° C is ${cToF}° F`); -console.log(`${fahrenheit}° F is ${fToC}° C`) +console.log(`${fahrenheit}°F is ${fToC}°C`) // ## Problem Five @@ -149,8 +149,8 @@ console.log(aliceA) let numberOfCats = 20 let numberOfDogs = 60 -let catPerc = (numberOfCats / (numberOfCats + numberOfDogs))*100 -let dogPerc = (numberOfDogs / (numberOfCats + numberOfDogs))*100 +let catPerc = ((numberOfCats / (numberOfCats + numberOfDogs))*100) +let dogPerc = ((numberOfDogs / (numberOfCats + numberOfDogs))*100) console.log(`The percentage of dogs in the daycare is ${dogPerc}% and the percentage of cats is ${catPerc}%.`)