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
6 changes: 6 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{}
72 changes: 64 additions & 8 deletions problems/variables.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +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.

const birthyear = 1997
let futureYear = 2034
let ageMin = futureYear - birthyear
let ageMax = ageMin + 1
console.log("I will be either " + ageMin + " or " + ageMax + " in " + futureYear)


// ## Problem Two

// Snack Supply Calculator:
Expand All @@ -16,6 +23,11 @@
// * 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 = 23
let maxAge = 55
let snack = 2
let snackNumber = (maxAge - currentAge) * 365 * snack
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
Expand All @@ -24,6 +36,11 @@
// * Calculate the area based on the radius, and log "The area is `areaOfCircle`".
// * Hint: https://www.w3schools.com/jsref/jsref_pi.asp

let radius = 100
let circumferenceResult = 2 * Math.PI * radius
let areaOfCircle = Math.PI * (radius ** 2)
console.log ("The circumference is " + circumferenceResult + " and the circle area is " + areaOfCircle)

// ## Problem Four

// Temperature Converter:
Expand All @@ -32,7 +49,13 @@
// * Now store a fahrenheit temperature into a variable.
// * Convert it to celsius and output "`tempInFahrenheit`°F is `tempInCelsius`°C."

let tempInCelsius = 50
let tempInFahrenheit = 1.8 * tempInCelsius + 32
console.log (tempInCelsius + ' °C is ' + tempInFahrenheit + ' °F')

let tempInFahrenheit1 = 1
let tempInCelsius1 = (tempInFahrenheit1 - 32) * (5/9)
console.log (tempInFahrenheit1 + ' °F is ' + tempInCelsius1 + ' °C')
// ## Problem Five

// Grades Calculator:
Expand All @@ -44,6 +67,18 @@
// * Find the average grade of all students
// * Print out if Dee's grade is higher than the class average

let aliceGrade = 45
let bobGrade = 78
let camGrade = 100
let currentAvg = ((aliceGrade + bobGrade + camGrade)/3)
let deeGrade = 100
let averageWithDee = ((aliceGrade + bobGrade + camGrade + deeGrade)/4)
console.log("Dee grade is higher than class average: " + deeGrade > averageWithDee)





// ## Problem Six

// Find the last number:
Expand All @@ -57,6 +92,10 @@
// Hint:
// Use the remainder % operator.

let a = 123
let lastDigit = a % 10
console.log (lastDigit)


// ## Problem Seven

Expand All @@ -82,6 +121,13 @@
// * alice + x = y * (bob + x)
// * Solve for alice

let bobAge = 12
let x = 3
let y = 2
let aliceAge = y * bobAge + (y - 1) * x
console.log (aliceAge)


// ## Problem Eight

// * Cat and Dog Percentages
Expand All @@ -95,6 +141,14 @@
// * 25% of the daycare animals are cats
// * 75% of the daycare animals are dogs

let numberOfCats = 20
let numberOfDogs = 60
let percentOfCats = (numberOfCats / (numberOfCats + numberOfDogs))
let percentOfDogs = (numberOfDogs / (numberOfCats + numberOfDogs))
let roundPercentOfDogs = Math.floor(percentOfDogs)
let roundpercentOfCats = Math.floor(percentOfCats)
console.log(roundPercentOfDogs + " of of the daycare animals are dogs")
console.log(roundPercentOfCats + " of of the daycare animals are cats")
// ## Problem Nine

// * Leap Year Calculator
Expand All @@ -106,7 +160,9 @@
// * 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 = 2020
let isLeapyear = (leapYear % 4 === 0) && (leapYear % 100 !== 0 || leapYear % 400 === 0)
console.log(((isLeapYear) && "Leap year!") && ((isLeapYear) || 'Not a leap year!')
// ## 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.
Expand All @@ -116,22 +172,22 @@
// let num1 = 2
// let num2 = 5
// let num3 = num1 * num2
// console.log(num3)
// console.log(num3) // 10
// ```
// '10'

// b.
// ```js
// let str = 'jel'
// str += 'lo'
// console.log(str)
// ```
// console.log(str) // jello

// `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
// ``