Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

print odd numbers in an array in javascript

[1,2,3,4].forEach((num) => num % 2 === 0 && console.log(num));
Comment

get odd number in array

public int[] findEvens() {
  int numberEvens = 0;
  for (int i = 0; i < numbers.length; i++) {
     if (numbers[i] % 2 == 0) {
        numberEvens++;
     }
  }
Comment

get odd number in array

public int[] findEvens() {
  int numberEvens = 0;
  for (int i = 0; i < numbers.length; i++) {
     if (i % 2 == 0) {
        numberEvens++;
     }
  }
Comment

how to find odd and even in a array

 public static void main(String[] args) {
        int[] xr = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10};
        for (int i = 0; i < xr.length; i++) {
            System.out.println(xr[i] % 2 == 0 ? xr[i] + " -> even" : xr[i] + " -> odd");
        }
    }
Comment

PREVIOUS NEXT
Code Example
Javascript :: nestjs version 
Javascript :: set url parameters javascript 
Javascript :: react disable eslint errors 
Javascript :: jboss session expiration time 
Javascript :: add jwt token in header 
Javascript :: scroll event js 
Javascript :: js onscroll event 
Javascript :: remove jquery 
Javascript :: react-router 
Javascript :: js insert emoji 
Javascript :: docs where field exists 
Javascript :: javascript get first 3 characters of string 
Javascript :: how to reset settimeout in javascript 
Javascript :: npm mongoose encryption 
Javascript :: two digit js' 
Javascript :: javascript separate string by char 
Javascript :: javascript sleep settimeout 
Javascript :: nextjs change port 
Javascript :: javascript quicksort 
Javascript :: send refresh token in axios interceptor 
Javascript :: array reverse algorithm in js 
Javascript :: on focus jquery 
Javascript :: find longest word in string javascript 
Javascript :: javascript file drag and drop 
Javascript :: cypress get selected dropdown value 
Javascript :: mongodb aggregate skip results 
Javascript :: npm yarn run shell script 
Javascript :: select all elements javascript 
Javascript :: how to remove duplicate values in array of objects using javascript 
Javascript :: set windows terminal as default vscode 
ADD CONTENT
Topic
Content
Source link
Name
1+8 =