array show even numbers in even positions code example
Example 1: If there are an odd number of elements in the array, return the element in the middle of the array.
public String middleElement(String[] array)
{
if (array.length >=1){
if (array.length %2 != 0){
return array[array.length/2];
}
else if(array.length %2 == 0){
return array[array.length/2];
}
return "";
}
else return "";
}
Example 2: find even numbers in an array javascript
arr.filter(num => num % 2)