Skip to content
Open
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
119 changes: 116 additions & 3 deletions problems/variables.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,23 @@
// * 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.
// node problems/variables.js

//const birthYear = 2000

//let futureYear = 2010

//let ageMin = futureYear - birthYear

//let ageMax = (futureYear - birthYear) + 1


//console.log("I will be either " + ageMin + " or " + ageMax + " in " + futureYear)






// ## Problem Two

Expand All @@ -16,6 +33,16 @@
// * 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 = 29

//const maximumAge = 35

//let snackPerDay = 10

//let snackNumber = ((maximumAge - currentAge) * (snackPerDay * 365))

//console.log("You will need " + snackNumber + " to last you until the age of " + maximumAge)

// ## Problem Three

// Calculate properties of a circle, using the definitions: http://math2.org/math/geometry/circles.htm
Expand All @@ -24,6 +51,23 @@
// * Calculate the area based on the radius, and log "The area is `areaOfCircle`".
// * Hint: https://www.w3schools.com/jsref/jsref_pi.asp

//let radiusOfCircle = 3

//let diameterOfCircle = radiusOfCircle * 2

//let circumferenceResult = 3.14 * diameterOfCircle

//let areaOfCircle = 3.14 * (radiusOfCircle)**2

//console.log("The circumference is" + circumferenceResult)

//console.log("The area is " + areaOfCircle)






// ## Problem Four

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

//let tempInCelsius = 10

//let tempInFahrenheit = (tempInCelsius * 9/5) + 32

//console.log(tempInCelsius + "C is " + tempInFahrenheit + "F")

//let tempInFahrenheit1 = 10

//let tempInCelsius1 = (tempInFahrenheit1 - 32) * 5/9

//console.log(tempInFahrenheit1 + "F is " + tempInCelsius1 + "C")


// ## Problem Five

Expand All @@ -44,6 +100,23 @@
// * Find the average grade of all students
// * Print out if Dee's grade is higher than the class average

//let alice = 60

//let bob = 70

//let cam = 80

//let classAverage = (alice + bob + cam) / 3

//let dee = 90

//let newClassAverage = (alice + bob + cam + dee) / 4

//console.log(newClassAverage <= dee)




// ## Problem Six

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

//let a = 123 % 4

//console.log(a)



// ## Problem Seven

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

//let bob1 = 12

//let x = 3

//let y = 2

//let alice = (y * (bob1 + x) - x

//console.log(alice)



// ## Problem Eight

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

//let numberOfCats = 20

//let numberOfDogs = 60

//let sumOfDaycare = numberOfDogs + numberOfCats

//let percentOfCat = ( numberOfCats / sumOfDaycare) * 100

//let percentOfDog = ( numberOfDogs / sumOfDaycare) * 100

//console.log(percentOfCat + "% of the daycare animals are cats")

//console.log(percentOfDog + "% of the daycare animals are dogs")



// ## Problem Nine

// * Leap Year Calculator
Expand All @@ -106,6 +212,13 @@
// * 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 && (leapYear % 100 && leapYear % 400)

//console.log((isLeapYear === 0 && "Leap Year!") || isLeapYear !== 0 "Not a leap year")



// ## Problem Ten: Predict the output

Expand All @@ -116,22 +229,22 @@
// 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
// ```