-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathproblem45.js
More file actions
37 lines (22 loc) · 804 Bytes
/
problem45.js
File metadata and controls
37 lines (22 loc) · 804 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
/*
## Practice Problem 45
**Write an arrow function where it will do the following:**
1. It will take an array where the array elements will be the
name of your friends
2. Check if the length of each element is even, push elements
with even length to a new array and return the result
Print the result.
*/
const findEven = nameList => {
const evenLengthName = [];
for(let i = 0; i < nameList.length; i++){
const friendName = nameList[i];
if(friendName.length % 2 == 0){
evenLengthName.push(friendName);
}
}
return evenLengthName;
}
const friendsName = ["Shourav", "Nirob", "Alal", "Jala", "Ashim", "Shipta", "Pritom", "Arko", "Alu"];
const evenLengthFriendsNameList = findEven(friendsName);
console.log(evenLengthFriendsNameList);