You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/App.js
+32-27Lines changed: 32 additions & 27 deletions
Original file line number
Diff line number
Diff line change
@@ -4,6 +4,9 @@ import './style.css';
4
4
Differences between forEach() and map() methods:
5
5
The forEach() method does not returns a new array based on the given array. The map() method returns an entirely new array. The forEach() method returns "undefined". The map() method returns the newly created array according to the provided callback function.1
6
6
*/
7
+
8
+
// ======Map vs forEach===========
9
+
7
10
constnumArr=[1,2,3];
8
11
constres=numArr.map((el)=>el*2);
9
12
console.log(numArr,res);
@@ -12,13 +15,13 @@ const res2 = numArr.forEach((val, i, arr) => (arr[i] = val * 2));
12
15
console.log(numArr,res2);
13
16
14
17
constperson={
15
-
name: "Deepak",
18
+
name: 'Deepak',
16
19
age: 28,
17
-
printInfo: function(){
20
+
printInfo: function(){
18
21
console.log(`My name is ${this.name} and my age is ${this.age}`);
19
-
}
20
-
}
21
-
person.printInfo()
22
+
},
23
+
};
24
+
person.printInfo();
22
25
23
26
exportdefaultfunctionApp(){
24
27
constERROR_MSG='Age is less than 18';
@@ -42,42 +45,44 @@ export default function App() {
42
45
);
43
46
}
44
47
48
+
// ============Merge 2 duplicate array and sort===========
0 commit comments