About 1,330,000 results
Open links in new tab
  1. javascript - How to write a function that returns the elements on odd

    Just filter the array returning an array with only odd values: var array = [1,2,3,4,5]; console.log(array.filter(function(el, ind){ return ind % 2 === 0; })); Share

  2. Print Odd Numbers in a JavaScript Array - GeeksforGeeks

    Jul 10, 2024 · JavaScript provides us with various approaches for printing odd numbers in an array. The core concept behind finding an odd number is based on the fundamental arithmetic …

  3. How to Find the Odd Numbers in an Array with JavaScript

    Jun 19, 2022 · To find the odd numbers in an array, we can call the Array filter() method, passing a callback that returns true when the number is odd, and false otherwise. The filter() method …

  4. Find the Even or Odd numbers in an Array in JavaScript

    Mar 3, 2024 · To find the even or odd numbers in an array: Use the Array.filter() method to iterate over the array. Check if each number has a remainder when divided by 2. The filter method …

  5. javascript - Find Index of SINGLE odd / even number in array

    Nov 12, 2019 · Given an array, remove zero or more elements to maximize the reduction where you add odd values and subtract even values

  6. JavaScript array split at odd index - Stack Overflow

    Mar 1, 2013 · Get thru your array with an index (i, perhaps) and check the value of i. if (i % 2 == 0){ goes_to_even_array(); ]else{ goes_odd_array(); }

  7. The JavaScript Array `filter ()` Method - Mastering JS

    Jul 1, 2020 · The index Argument. JavaScript calls the filter() callback with 3 arguments. The first argument is the element in the array, and the 2nd argument is the index in the array. For …

  8. Print all Odd Numbers in a Range in JavaScript Array

    May 20, 2024 · Odd numbers are numbers that cannot be divided into equal parts. If we divide the odd number by 2, the remainder is 1. In JavaScript, if we want to print all Odd numbers in a …

  9. Find Odd Numbers In An Array In JavaScript – typedarray.org

    Jun 24, 2022 · To find odd numbers in an array in JavaScript – Use the filter() method, passing it a function. In each iteration, check if the current number is not divisible by 2, if it isn’t, then it …

  10. Matching Odd and Even Indices with Values in JavaScript

    Jan 18, 2021 · Learn how to match odd and even indices with values in JavaScript through this comprehensive guide, including examples and explanations. Discover techniques for matching …

  11. Some results have been removed
Refresh