From 204f032238c4527114270c35c5befeccfc357d74 Mon Sep 17 00:00:00 2001 From: Rob <40747n@gmail.com> Date: Tue, 8 Dec 2020 23:50:46 -0500 Subject: [PATCH 1/2] 1st submitt --- problems/variables.js | 55 +++++++++++++++++++++++++++++++++++++++---- 1 file changed, 51 insertions(+), 4 deletions(-) diff --git a/problems/variables.js b/problems/variables.js index 831a97c..734da67 100644 --- a/problems/variables.js +++ b/problems/variables.js @@ -6,6 +6,11 @@ // * 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. +const age = 1978; +const futureYear = 2032; +let ageMax = furtureYear - age; +let ageMin = ageMax - 1; +console.log("I will be either " + ageMin + " or " + ageMax + " in " futureYear); // ## Problem Two @@ -15,6 +20,13 @@ // * 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 age = 28; +const maxAge = 35; +let snackAmount = 2; +let snackNumber = snackAmount * 365; +let snackYear = maxAge - age; +let totalSnack = snackYear * snackNumber; +console.log('You will need ' + totalSnack + ' tolast you until the age of ' + maxAge); // ## Problem Three @@ -23,6 +35,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 = 12; +let circumference = 2 * Math.PI * radius; +console.log('The circumference is ' + circumference); +let areaOfCircle = Math.PI * radius ** 2; +console.log('The area is ' + areaOfCircle); // ## Problem Four @@ -31,6 +48,13 @@ // * 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 = 28; +let tempInFahrenheit = (tempInCelsius * 9/5) + 32; +console.log(tempInCelsius + ' ºC is ' + tempInFahrenheit + ' ºF'); +let tempInFahrenheit2 = 82.4; +let tempInCelsius2 = (tempInFahrenheit2 -32) * 5/9; +console.log.apply(tempInFahrenheit2 + ' ºF is ' + tempInCelsius2 + ' ºC'); + // ## Problem Five @@ -43,6 +67,13 @@ // * 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 = 98; +let bobGrade = 88; +let camGrade = 78; +let avgGrade = (aliceGrade + bobgrade + camGrade) / 3; +let deeGrade = 68; +let avgAll = (aliceGrade + bobGrade + camGrade + deeGrade / 4); +console.log(deeGrade + ' is lower than ' + avgAll); // ## Problem Six @@ -56,6 +87,8 @@ // Hint: // Use the remainder % operator. +let a = 522; +console.log(a % 5); // ## Problem Seven @@ -81,6 +114,11 @@ // * Hint: // * alice + x = y * (bob + x) // * Solve for alice +let x = 12; +let y = 2; +let bob = 12; +let alice = (bob + x) * y - x; +console.log(alice); // ## Problem Eight @@ -94,6 +132,13 @@ // * Output: // * 25% of the daycare animals are cats // * 75% of the daycare animals are dogs +let numberOfCats = 12; +let numberOfDogs = 24; +let totalAnimals = numberOfCats + numberOfDogs; +let percentageOfCat = Math.floor(numberOfCats * 100 / totalAnimals); +let percentageOfDog = Math.floor(numberOfDogs * 100 / totalAnimals); +console.log(percentageOfDog + ' % of the daycare amimals are dogs'); +console.log(percentageOfCat + ' % of the daycare animals are cats'); // ## Problem Nine @@ -105,7 +150,9 @@ // * The above rule is valid except that every 100 years special rules apply. // * Years that are divisible by 100 are not leap years if they are not also divisible by 400. // * 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. - +let leapYear = 3258; +let isLeapYear = leapYear % 4 && (leapYear % 100 && leapYear % 400); +console.log(isLeapYear === 0 && 'Leap Year!') || isLeapYear !== 0 && 'Not a leap year!'); // ## Problem Ten: Predict the output @@ -116,14 +163,14 @@ // 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. @@ -131,7 +178,7 @@ // let string = 'My favorite number is '; // let number = 42 // let sentence = string + number -// console.log(typeof(sentence)) +// console.log(typeof(sentence)) // string ('My favorite number is 42') // ``` From f0daa1224c9c42cb02f225b0603b96a92d8ebd11 Mon Sep 17 00:00:00 2001 From: Rob <40747n@gmail.com> Date: Wed, 9 Dec 2020 00:02:15 -0500 Subject: [PATCH 2/2] 1st submit --- problems/variables.js | 1 + 1 file changed, 1 insertion(+) diff --git a/problems/variables.js b/problems/variables.js index 734da67..e25cf20 100644 --- a/problems/variables.js +++ b/problems/variables.js @@ -182,3 +182,4 @@ console.log(isLeapYear === 0 && 'Leap Year!') || isLeapYear !== 0 && 'Not a leap // ``` +