forked from Ajay-Mohanraj/TTRWorkshops
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIntroToJS.js
50 lines (41 loc) · 1.08 KB
/
IntroToJS.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
// hello world workshop
const int = 1;
const float = 2.3;
const double = 3.7;
const boolean = true;
const char = 'w';
const string = 'hello world';
console.log(int);
console.log(float);
console.log(double);
console.log(boolean);
console.log(char);
console.log(string);
// Arithmetic operators
let num1 = 10;
var num2 = 4;
const addition = num1 + num2; // 10+4 = 14
console.log("10 + 4 = " + addition);
const subtraction = num1 - num2; //10-4 = 6
console.log("10 - 4 = " + subtraction);
const multiplication = num1 * num2; //10 *4 = 40;
console.log("10 x 4 = " + multiplication);
const division = num1 / num2; // 10/4 = 2.5;
console.log("10 / 4 = " + division);
// conditional operators
var parameter1 = 4;
var parameter2 = 8;
function numberComparer(num1, num2) {
if (num1 > num2) {
console.log(num1 + " is larger than " + num2);
}
else if (num2 > num1) {
console.log(num2 + " is larger than " + num1);
}
else {
console.log("num1 is equal to num2.");
}
parameter1 = 10;
}
numberComparer(parameter1, parameter2)
numberComparer(parameter1, parameter2)