1let getEvenNumbers = () => {
2 let arr = [4,5,7,8,14,45,76];
3
4 let the_evens = arr.filter(number => number % 2 == 0);
5 document.write('Even Numbers: ' + the_evens);
6}
7
8getEvenNumbers();
1/**
2 * This program displays even values
3 * of array.
4 */
5public class EvenArray
6{
7 public static void main(String[] args)
8 {
9 int[] list = { 2, 5, 16, 18, 21 };
10
11 // Display all even elements of array
12 System.out.println("The even numbers of array:");
13
14 for (int i = 0; i < list.length; i++)
15 {
16 if (list[i] % 2 == 0)
17 {
18 System.out.print(list[i] + " ");
19 }
20 }
21
22 System.out.println();
23 }
24}