forked from foocoding/JavaScript2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmap-filter.js
More file actions
31 lines (24 loc) · 684 Bytes
/
map-filter.js
File metadata and controls
31 lines (24 loc) · 684 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
'use strict';
/* function doubleOddNumbers(numbers) {
// Replace this comment and the next line with your code
console.log(numbers);
}
const myNumbers = [1, 2, 3, 4];
console.log(doubleOddNumbers(myNumbers));
// Do not change or remove anything below this line
module.exports = {
myNumbers,
doubleOddNumbers,
}; */
function doubleOddNumbers(numbers) {
const oddNumbers = numbers.filter(num => num % 2 !== 0);
const doubleNumbers = oddNumbers.map(num => num * 2);
return doubleNumbers;
}
const myNumbers = [1, 2, 3, 4];
console.log(doubleOddNumbers(myNumbers));
// Do not change or remove anything below this line
module.exports = {
myNumbers,
doubleOddNumbers,
};