-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
40 lines (36 loc) · 1.12 KB
/
Copy pathindex.js
File metadata and controls
40 lines (36 loc) · 1.12 KB
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
function mapFilRed(){
const users = [
{ fN: "Megha", lN: "Chauhan", age: 19 },
{ fN: "Richa", lN: "Chauhan", age: 23 },
{ fN: "Taylor", lN: "Swift", age: 33 },
{ fN: "Harry", lN: "Styles", age: 29}
];
alert("Open Console");
console.log("This shows the working of map(), filter() and reduce()");
console.log("Print the names of users who are less than 27 years of age: (using Filter and Map)");
const output = users.filter((x) => x.age<27).map((x) => x.fN)
console.log(output);
const vut = users.reduce(function(acc, curr){
if(curr.age < 27){
acc.push(curr.fN);
}
return acc;df
}, []);
console.log("Print the names of users who are less than 27 years of age: (using only Reduce)");
console.log(vut);
}
let mySW;
function counter(){
alert("Open Console");
let timer = 0;
function sWatcho(){
timer++;
//console.clear();
console.log(timer);
}
mySW = setInterval(sWatcho,1000);
}
function stopCounter(){
clearInterval(mySW);
console.log("Terminating counter");
}