-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfundamentals.js
53 lines (39 loc) · 904 Bytes
/
fundamentals.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
// How to declare a variable using let const
const name = 'jerry';
let season = 'rainy';
season = 'winter';
// 6 basic condition >,<,===,!==,<=,>=
// multiple condition: &&, ||
if (name === 'Jerry' || season === 'rainy') {
}
else if (name === 'jerry') {
}
else {
}
// 3. Array
// Index
// length, push
const numbers = [2, 45, 65, 43, 2, 1, 9];
numbers[0] = 56;
// loop
for (let i = 0; i < numbers.length; i++) {
const number = numbers[i];
console.log(number);
}
// function
function multiply(num1, num2) {
const result = num1 * num2;
return result;
}
const output = multiply(2, 3);
console.log(output);
// object
const student = {
name: 'jerin',
id: 38,
age: 23,
}
const myVariable = 'age';
console.log(student.age);
console.log(student['age']); /* access via property name string */
console.log(student[myVariable]); /* Access via property name in a variable */