-
Notifications
You must be signed in to change notification settings - Fork 166
Carina Taveras #161
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Carina Taveras #161
Changes from all commits
7f27218
bef3f65
2f4b7de
939e02c
d52e9da
628490b
7f3b073
22a796d
37319d2
f7d568b
327e197
306efd5
197dc0d
73e31a2
9d61004
cd05eab
3b44b73
5c644a5
aefcd20
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,6 +7,14 @@ | |
| // * 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 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 | ||
|
|
||
| // Snack Supply Calculator: | ||
|
|
@@ -16,14 +24,27 @@ | |
| // * 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)) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good use of equation. This is the type of solution I want to see in Question 1 |
||
|
|
||
| console.log(`You will need ${snackNumber} snacks 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`". | ||
| // * 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 areaOfCircle = (radius * radius * Math.PI) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice job using Math library. Can also us it for Math.pow(radius, 2) |
||
| let circumferenceOfCircle = (Math.PI * radius * 2) | ||
| console.log(`The circumference is ${circumferenceOfCircle} and the area is ${areaOfCircle}.`) | ||
| // ## Problem Four | ||
|
|
||
| // Temperature Converter: | ||
|
|
@@ -32,6 +53,14 @@ | |
| // * Now store a fahrenheit temperature into a variable. | ||
| // * Convert it to celsius and output "`tempInFahrenheit`°F is `tempInCelsius`°C." | ||
|
|
||
| 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 | ||
|
|
||
|
|
@@ -44,6 +73,16 @@ | |
| // * 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) | ||
| let dee = 90 | ||
| average = ((bob + cam + alice + dee) / 4) | ||
|
|
||
| if(dee > average ) console.log(`Dees grade is higher than average`) | ||
|
|
||
|
|
||
| // ## Problem Six | ||
|
|
||
| // Find the last number: | ||
|
|
@@ -53,6 +92,11 @@ | |
| // * a = 123 | ||
| // * Output: | ||
| // * 3 | ||
|
|
||
| let a = 6790 | ||
| let output = a % 10 | ||
|
|
||
| console.log(`The last digit of ${a} is ${output}.`) | ||
|
|
||
| // Hint: | ||
| // Use the remainder % operator. | ||
|
|
@@ -82,6 +126,13 @@ | |
| // * 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 | ||
|
|
@@ -95,6 +146,15 @@ | |
| // * 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 | ||
|
|
@@ -107,6 +167,20 @@ | |
| // * 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)) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Always use triple equals === (strict equaltiy) |
||
| { | ||
| 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. | ||
|
|
@@ -116,22 +190,20 @@ | |
| // 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. | ||
| // ```js | ||
| // let string = 'My favorite number is '; | ||
| // let number = 42 | ||
| // let sentence = string + number | ||
| // console.log(typeof(sentence)) | ||
| // console.log(typeof(sentence))/string | ||
| // ``` | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Age should be numbers on strings