repl.it
@MIhm7904/

ProblemSet1

Nodejs

Problem Set 1: Primitive Data Types

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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
//Write out your first name as a string and your last name as a string.

"Megan"

"Ihm"

//Print your first and last name separately using console.log method.

console.log("Megan")

console.log("Ihm")

//Print first and last name out in the same line of code using concatenation.

console.log("Megan " + "Ihm")

//In written form, explain what a string is and what every string requires.

//A string is a way to represent text.  Every string needs double quotes, single quotes, or back ticks.


//In written form, explain what an integer is and what a float is.  How do they differ from strings?

//An integer is a whole number and a float is a number with decimal points.  Javascript understands these numbers differently than the string representation of a number.  If you want to perform any math, you need to make sure your number is an integer or float.

//Using the Javascript console, practice mathematical operations.  Addition, Subtraction, Multiplication, Division, Modulus, Incrementing, Decrementing, and Exponents.

//Addition

console.log(2 + 3)

//Subtraction

console.log(5 - 3)

//Multiplication

console.log(5 * 5)

//Division

console.log(25 / 5)

//Modulus

console.log(25 % 2)

//Incrementing

let a = 1
console.log(++a)

//Decrementing

let b = 1
console.log(--b)

//Exponents

console.log(Math.pow(5, 2))

//Comparison Operators

let x = 5
//equal to
console.log(x == 8)
console.log(x == 5)
//greater than
console.log(x > 8)
//greater than or equal to
console.log(x >= 8)
//less than
console.log(x < 8)
//less than or equal to
console.log(x <= 8)