-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.js
94 lines (73 loc) · 1.66 KB
/
main.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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
//strings
console.log("ksjef swkefjbnwakeb 343543 %$#")
console.log('ksjef swkefjbnwakeb 343543 %$#')
console.log("1000")
console.log('1000')
// numbers
console.log(1000)
console.log(-1000.34534)
// boolean
console.log(true)
console.log(false)
// variables
var a = 10
var b = 20
var sum = a + b
console.log("Sum is :", a - b)
let s = "Kelvin"
console.log("My name is :", s)
let boolValue = true
console.log("Is the truthy value", boolValue)
// Arrays
let arr = [1, 4, 6, 32, 6]
console.log("Array value is ", arr)
console.log("Array value is at index 3", arr[3])
// let arrB = arr
let arrB = [...arr]
arr[1] = 400
console.log("Array value is ", arr)
console.log("Array value of arrB is ", arrB)
// Objects
let objValue = {
key: "value 0",
key1: 20,
name: "kelvin",
arr0: ["a", "abc", "abcd", 48, [3, 4, [5, 6, 7]]],
3: false,
sumFN: function(a, b) {
let data = a + b
return {
dataValue: data
}
}
}
let keyName = "key"
objValue.key = "kelvin"
console.log("objValue.key value is ", objValue.key)
console.log("objValue[keyName] value is ", objValue[keyName])
console.log("objValue.arr0[2] value is ", objValue.arr0[4][2][1])
console.log("objValue.sumFN(10,20) value is ", objValue.sumFN(a, b))
function findSum(x, y) {
let data = x + y
return {
dataValue: data
}
}
/* let findSum = function mySum(x,y){
let data = x+y
return { dataValue: data}
}
*/
let ans = findSum(10, 20)
console.log("function sum return value", ans)
// If-Else
let time = "10"
let greeting;
if (time === 10) {
greeting = "Good morning";
} else if (time < 20) {
greeting = "Good day";
} else {
greeting = "Good evening";
}
console.log("greeting:", greeting)