Answers for "an array of odd numbers between 1 and 10 javascript"

2

js array value that appears odd number of times

// Find the odd int
function findOdd(A) {
  return A.reduce((a, b) => a ^ b);
}

console.log(findOdd([20,1,-1,2,-2,3,3,5,5,1,2,4,20,4,-1,-2,5], 5)); // 5
console.log(findOdd([1,1,2,-2,5,2,4,4,-1,-2,5], -1)); // -1
console.log(findOdd([20,1,1,2,2,3,3,5,5,4,20,4,5], 5)); // 5
Posted by: Guest on March-18-2021
0

javascript find all odd between two numbers

function oddNumbers(l, r) {
    let arr = [];
    while (l <= r) {
        arr.push(l);
        l += 1;
    };
    return arr.filter(n => n % 2);
}
Posted by: Guest on January-04-2021

Code answers related to "an array of odd numbers between 1 and 10 javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language