-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcallbacks.html
More file actions
40 lines (34 loc) · 1.04 KB
/
Copy pathcallbacks.html
File metadata and controls
40 lines (34 loc) · 1.04 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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
function myFilter(my_array, callback){
//Enter your code here
let result=[];
for(let n of my_array){
if(callback(n)){
result.push(n) ;
}
}
return result;
}
function processData(inputArray) {
//In blank write anonymous function, which takes one parameter and returns true if its even or false if its odd.
console.log(myFilter(inputArray, (n)=>{if(n%2==0)return true;else return false;}));
}
process.stdin.resume();
process.stdin.setEncoding("ascii");
_input = "";
process.stdin.on("data", function (input) {
_input += input;
});
process.stdin.on("end", function () {
processData(_input.split(' ').map(num => Number(num)));
});
</body>
</html>