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
105 changes: 101 additions & 4 deletions problems/variables.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,15 @@
// * 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 = 1993
// let futureYear = 3241
// let ageMax = futureYear-birthYear
// let ageMin = ageMax - 1

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



// ## Problem Two

// Snack Supply Calculator:
Expand All @@ -16,6 +25,17 @@
// * 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`".

// const maxAge = 30
// let currentAge = 28
// let snackNumber = 4
// console.log ((maxAge - currentAge)* 365 * snackNumber)

// snackNumber = 2920
// console.log ("you will need "+ snackNumber +" to last you until "+ maxAge)




// ## Problem Three

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


// let radius = 5
// let Pi = (Math.PI)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need for parenthesis here and variables should be camelCase.

// let circumferenceResult = (2 * Pi * radius)
// console.log ("The circumference " + "is " + circumferenceResult )
// let areaOfCircle = (Pi * radius * radius)
// console.log ("The area is " + areaOfCircle)



// ## Problem Four

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

// let tempInCelsius = 100
// let tempInFahrenheit = tempInCelsius * 1.8 + 32
// console.log (tempInCelsius + "°C is " + tempInFahrenheit + "°F")
// tempInFahrenheit = 50
// tempInCelsius = ((tempInFahrenheit - 32) / 1.8 )
// console.log ( tempInFahrenheit + "°F is " + tempInCelsius + "°C.")





// ## Problem Five

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

// let alicesGrade = 90
// let bobsGrade = 80
// let camsGrade = 85
// let averageGrade = (alicesGrade + bobsGrade + camsGrade) / 3
// console.log ( "The average grade is " + averageGrade )
// let deesGrade = 95
// averageGrade = (alicesGrade + bobsGrade + camsGrade + deesGrade) / 4
// console.log ( " The average grade of all the students is " + averageGrade )
// console.log ( " Dees grade of " + deesGrade + " is higher than the class average of " + averageGrade )
<<<<<<< HEAD
=======

>>>>>>> e2c626cfce0b6bd6ad8f4cca48f17fb457c7d574
// ## Problem Six

// Find the last number:
Expand All @@ -53,10 +106,18 @@
// * a = 123
// * Output:
// * 3

// Hint:
// Use the remainder % operator.

// let a = 28
// let output = a % 10

// console.log ("The last digit of " + a + " is " + output)






// ## Problem Seven

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

// const bobAge = 12
// let futureYear = 3
// let productAge = 2
// let aliceAge = (bobAge + futureYear) * productAge - futureYear

// console.log ("Alice age is " + aliceAge)

// futureYear = 1
// productAge = 3
// aliceAge = (bobAge + futureYear) * productAge - futureYear

// console.log ("Alice new age is " + aliceAge)



// ## Problem Eight

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

// let numberOfCats = 20
// let numberOfDogs = 60
// let percentageOfCats = numberOfCats / (numberOfCats + numberOfDogs) * 100
// let percentageOfDogs = numberOfDogs / (numberOfCats + numberOfDogs) * 100
// console.log (percentageOfCats + "% of the daycare animals are cats")
// console.log (percentageOfDogs + "% of the daycare animals are dogs")


// ## Problem Nine

// * Leap Year Calculator
Expand All @@ -116,22 +200,35 @@
// let num1 = 2
// let num2 = 5
// let num3 = num1 * num2
// console.log(num3)
// console.log(num3) //'10'
// ```

// let num1 = 2
// let num2 = 5
// let num3 = num1 * num2
// console.log(num3)

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

// 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))
// console.log(typeof(sentence)) // 'string'
// ```

// let string = 'My favorite number is'
// let number = 42
// let sentence = string + number
// console.log (typeof(sentence))