repl.it
@MIhm7904/

ProblemSet2

Nodejs

Problem Set 2: Variables

fork
loading
Files
  • index.js
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
//Refactor your coded from problem set one to use variables.  Create a variable for your first name and one for your last name.  Print them on separate lines and then try printing them on the same line.

let firstName = "Megan "

let lastName = "Ihm"

console.log(firstName)

console.log(lastName)

console.log(firstName + lastName)

//Assign the following values to variables.  Decide how best to name them and if they should be created with const or let.  There are a couple ways to think about each one.  Write a brief sentence about why you choose the variable name you did and why you chose const or let.

//The year 1776

const birthYearOfAmerica = 1776

console.log(birthYearOfAmerica)

//I choose the name birthYearOfAmerica because it provides detail to the exact year.  I made the variable using const because the year will never change.

//your age

const myBirthYear = 1980

let currentYear = 2019

console.log(currentYear - myBirthYear)

//I choose the name myBirthYear to represent the year I was born, and currentYear to represent the year that it is.  I made myBirthYear const because it will never change, and currentYear let because it will change.

//The Golden Ratio

const theGoldenRatio = 1.6180

console.log(theGoldenRatio)

//I choose the name theGoldenRatio because it specifically indicates this number.  I made the variable a const because it does not change.


//The name of your home country

let myHomeCountry = "United States of America"

console.log(myHomeCountry)

//I choose the name myHomeCountry to represent the country I consider home.  I made the variable let, because it can be subject to change.

//The total change due for a $25.76 bill paid for with a $50 bill.

const fiftyDollarBill = 50.00

let billDue = 25.76

console.log(fiftyDollarBill - billDue.toFixed(2))

//I choose fiftyDollarBill to represent $50, and billDue as amount due.  I made fiftyDollarBill const because it will never change, and billDue let because it will change.