-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathobject.js
More file actions
67 lines (38 loc) · 919 Bytes
/
Copy pathobject.js
File metadata and controls
67 lines (38 loc) · 919 Bytes
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
let obj = {
name: "Sourav",
age: 23,
job: "Developer"
};
console.log(obj);
function sum(x, y) {
return x + y;
}
console.log(sum(6, 9));
const array1 = [1, 2, 3];
const array2 = [4, 5, 6];
const mergedArray = [];
for (let i = 0; i < array1.length; i++) {
mergedArray.push(array1[i]);
}
for (let i = 0; i < array2.length; i++) {
mergedArray.push(array2[i]);
}
console.log(mergedArray);
const arr = [10, 20, 25, 100, 40];
function bubbleSort(arr) {
let n = arr.length;
const arr = [10, 20, 25, 100, 40];
function bubbleSort(arr) {
let n = arr.length;
// Traverse through all array elements
for (let i = 0; i < n - 1; i++) {
for (let j = 0; j < n - 1 - i; j++) {
// Swap if element is greater than next index
if (arr[j] > arr[j + 1]) {
[arr[j], arr[j + 1]] = [arr[j + 1], arr[j]];
}
}
}
return arr;
}
console.log(bubbleSort(arr));