From db94643f1f2f4ea6b22a9d1c7bf5a8064818bc87 Mon Sep 17 00:00:00 2001 From: "D.Morales" Date: Tue, 8 Dec 2020 22:17:04 -0500 Subject: [PATCH 1/4] complete --- problems/variables.js | 65 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/problems/variables.js b/problems/variables.js index 831a97c..d0bb57d 100644 --- a/problems/variables.js +++ b/problems/variables.js @@ -134,4 +134,69 @@ // console.log(typeof(sentence)) // ``` +//question 1 +const birthYear = 1965 +let futureYear = 2022 +let ageMin = 2022 - birthYear - 1 +let ageMax = 2022 - birthYear +console.log('In ' + futureYear + ' I will either be ' + ageMin + ' or ' + ageMax ) + +//question 2 +let currentAge = 54 +const maxAge = 200 +let snackNumber = 2 +let yearsGoneBy = maxAge - currentAge +console.log('I will need ' + snackNumber * yearsGoneBy + ' snacks to last until the age of ' + yearsGoneBy) + +//question 3 +let radius = 2 +let circumferenceResult = (Math.PI*2) * radius +console.log('The circumference is ' + circumferenceResult) +let area = Math.PI * (radius**2) +console.log('The area is ' + area) + +//question 4 +let tempInCelsius = 0 +let tempInFahrenheit = 32 +console.log(tempInFahrenheit + "°F is " + tempInCelsius + "°C") +// ## Problem Five +let aliceGrade = 20 +let bobGrade = 75 +let camGrade = 100 +let threeStudents = aliceGrade + bobGrade + camGrade +let avg1 = threeStudents / 3 +let deesGrade = 100 +let fourStudents = threeStudents + deesGrade +let avg2 = fourStudents / 4 +console.log("Dee's grade of " + deesGrade + "% is higher the the class average of " + avg2 + "%") + +// ## Problem Six +let a = 5002 +let output = a % 5000 +console.log(output) + +// ## Problem Seven +let x = 3; +let y = 2; +const bob = 12; +let aliceAge = y * ( bob + x) - x; +console.log(aliceAge); + +// # Problem Eight +numberOfCats = Math.floor (45.4) +numberOfDogs = Math.floor (55.4) +console.log(numberOfCats + " of the daycare animals are cats") +console.log(numberOfDogs + " of the daycare animals are Dogs") + +// # Problem Nine +TO BE CONTINUED + +// ## Problem Ten: Predict the output + +//a +console.log(10) +//b +console.log('jello') +//c +console.log(typeof'My favorite number is 42') \ No newline at end of file From a42f68d1a06b90c14bd2293d3056cb38fadcc660 Mon Sep 17 00:00:00 2001 From: "D.Morales" Date: Tue, 8 Dec 2020 22:21:49 -0500 Subject: [PATCH 2/4] complete --- problems/variables.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/problems/variables.js b/problems/variables.js index d0bb57d..5181e9f 100644 --- a/problems/variables.js +++ b/problems/variables.js @@ -190,7 +190,7 @@ console.log(numberOfCats + " of the daycare animals are cats") console.log(numberOfDogs + " of the daycare animals are Dogs") // # Problem Nine -TO BE CONTINUED +//TO BE CONTINUED // ## Problem Ten: Predict the output @@ -199,4 +199,8 @@ console.log(10) //b console.log('jello') //c -console.log(typeof'My favorite number is 42') \ No newline at end of file +console.log(typeof'My favorite number is 42') + +let age = 20; +age = 21; +console.log(age); \ No newline at end of file From 0db186da73bcfd81c02debf12c48e454659dd9cb Mon Sep 17 00:00:00 2001 From: "D.Morales" Date: Wed, 9 Dec 2020 00:44:28 -0500 Subject: [PATCH 3/4] the real completion --- problems/variables.js | 143 +++++++++++++++--------------------------- 1 file changed, 51 insertions(+), 92 deletions(-) diff --git a/problems/variables.js b/problems/variables.js index 5181e9f..af12f6a 100644 --- a/problems/variables.js +++ b/problems/variables.js @@ -6,15 +6,29 @@ // * Calculate your 2 possible ages for that year based on the stored values. // * 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. +//question 1 +const birthYear = 1965 +let futureYear = 2022 +let ageMin = 2022 - birthYear - 1 +let ageMax = 2022 - birthYear +console.log('In ' + futureYear + ' I will either be ' + ageMin + ' or ' + ageMax ) + + // ## Problem Two + // Snack Supply Calculator: // * Store your current age in a variable. // * Store a maximum age in a constant variable. // * Store an estimated snack amount per day (as a number). // * 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`". +let currentAge = 54 +const maxAge = 200 +let snackNumber = 2 +let yearsGoneBy = maxAge - currentAge +console.log('I will need ' + snackNumber * yearsGoneBy + ' snacks to last until the age of ' + yearsGoneBy) // ## Problem Three @@ -23,6 +37,11 @@ // * Calculate the circumference based on the radius, and log "The circumference is `circumferenceResult`". // * Calculate the area based on the radius, and log "The area is `areaOfCircle`". // * Hint: https://www.w3schools.com/jsref/jsref_pi.asp +let radius = 2 +let circumferenceResult = (Math.PI*2) * radius +console.log('The circumference is ' + circumferenceResult) +let area = Math.PI * (radius**2) +console.log('The area is ' + area) // ## Problem Four @@ -31,7 +50,9 @@ // * Convert it to fahrenheit and output "`tempInCelsius`°C is `tempInFahrenheit`°F". // * Now store a fahrenheit temperature into a variable. // * Convert it to celsius and output "`tempInFahrenheit`°F is `tempInCelsius`°C." - +let tempInCelsius = 0 +let tempInFahrenheit = 32 +console.log(tempInFahrenheit + "°F is " + tempInCelsius + "°C") // ## Problem Five @@ -43,6 +64,15 @@ // * Store Dee's grade on a test to a variable // * Find the average grade of all students // * Print out if Dee's grade is higher than the class average +let aliceGrade = 20 +let bobGrade = 75 +let camGrade = 100 +let threeStudents = aliceGrade + bobGrade + camGrade +let avg1 = threeStudents / 3 +let deesGrade = 100 +let fourStudents = threeStudents + deesGrade +let avg2 = fourStudents / 4 +console.log("Dee's grade of " + deesGrade + "% is higher the the class average of " + avg2 + "%") // ## Problem Six @@ -53,7 +83,9 @@ // * a = 123 // * Output: // * 3 - +let a = 5002 +let output = a % 5000 +console.log(output) // Hint: // Use the remainder % operator. @@ -77,7 +109,11 @@ // * bob = 12 // * Expected values: // * alice = 38 - +let x = 3; +let y = 2; +const bob = 12; +let aliceAge = y * ( bob + x) - x; +console.log(aliceAge); // * Hint: // * alice + x = y * (bob + x) // * Solve for alice @@ -95,6 +131,17 @@ // * 25% of the daycare animals are cats // * 75% of the daycare animals are dogs +//numberOfCats = Math.floor (45.4) +//numberOfDogs = Math.floor (55.4) + +let dogs = 154 +let cats = 53 +let total = dogs + cats +numberOfCats = cats/total * 100 +numberOfDogs = dogs/total * 100 +console.log(numberOfCats + "%" + " of the daycare animals are cats") +console.log(numberOfDogs + "%" + " of the daycare animals are Dogs") + // ## Problem Nine // * Leap Year Calculator @@ -110,97 +157,9 @@ // ## 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. - -// a. -// ```js -// let num1 = 2 -// let num2 = 5 -// let num3 = num1 * num2 -// console.log(num3) -// ``` - -// b. -// ```js -// let str = 'jel' -// str += 'lo' -// console.log(str) -// ``` - -// c. -// ```js -// let string = 'My favorite number is '; -// let number = 42 -// let sentence = string + number -// console.log(typeof(sentence)) -// ``` - -//question 1 -const birthYear = 1965 -let futureYear = 2022 -let ageMin = 2022 - birthYear - 1 -let ageMax = 2022 - birthYear -console.log('In ' + futureYear + ' I will either be ' + ageMin + ' or ' + ageMax ) - -//question 2 -let currentAge = 54 -const maxAge = 200 -let snackNumber = 2 -let yearsGoneBy = maxAge - currentAge -console.log('I will need ' + snackNumber * yearsGoneBy + ' snacks to last until the age of ' + yearsGoneBy) - -//question 3 -let radius = 2 -let circumferenceResult = (Math.PI*2) * radius -console.log('The circumference is ' + circumferenceResult) -let area = Math.PI * (radius**2) -console.log('The area is ' + area) - -//question 4 -let tempInCelsius = 0 -let tempInFahrenheit = 32 -console.log(tempInFahrenheit + "°F is " + tempInCelsius + "°C") - -// ## Problem Five -let aliceGrade = 20 -let bobGrade = 75 -let camGrade = 100 -let threeStudents = aliceGrade + bobGrade + camGrade -let avg1 = threeStudents / 3 -let deesGrade = 100 -let fourStudents = threeStudents + deesGrade -let avg2 = fourStudents / 4 -console.log("Dee's grade of " + deesGrade + "% is higher the the class average of " + avg2 + "%") - -// ## Problem Six -let a = 5002 -let output = a % 5000 -console.log(output) - -// ## Problem Seven -let x = 3; -let y = 2; -const bob = 12; -let aliceAge = y * ( bob + x) - x; -console.log(aliceAge); - -// # Problem Eight -numberOfCats = Math.floor (45.4) -numberOfDogs = Math.floor (55.4) -console.log(numberOfCats + " of the daycare animals are cats") -console.log(numberOfDogs + " of the daycare animals are Dogs") - -// # Problem Nine -//TO BE CONTINUED - -// ## Problem Ten: Predict the output - -//a +/a console.log(10) //b console.log('jello') //c console.log(typeof'My favorite number is 42') - -let age = 20; -age = 21; -console.log(age); \ No newline at end of file From 9c1f57a5e57e87a5db55a3739bcf5c1130291cd3 Mon Sep 17 00:00:00 2001 From: "D.Morales" Date: Wed, 9 Dec 2020 00:49:03 -0500 Subject: [PATCH 4/4] Finally Done --- problems/variables.js | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/problems/variables.js b/problems/variables.js index af12f6a..1c14bce 100644 --- a/problems/variables.js +++ b/problems/variables.js @@ -131,16 +131,13 @@ console.log(aliceAge); // * 25% of the daycare animals are cats // * 75% of the daycare animals are dogs -//numberOfCats = Math.floor (45.4) -//numberOfDogs = Math.floor (55.4) - -let dogs = 154 -let cats = 53 +let dogs = 20 +let cats = 60 let total = dogs + cats numberOfCats = cats/total * 100 numberOfDogs = dogs/total * 100 console.log(numberOfCats + "%" + " of the daycare animals are cats") -console.log(numberOfDogs + "%" + " of the daycare animals are Dogs") +console.log(numberOfDogs + "%" + " of the daycare animals are dogs") // ## Problem Nine