how to find even or odd numbers in array in javascript| Coding Interview Questions #7

preview_player
Показать описание
Javascript Coding Interview Questions - #7 | Javascript Coding Challenge Interview Questions 2022
how to find even or odd numbers in array in javascript?
in this series we cover javascript interview questions and answers mostly asked in year 2021-2020, javascript interview questions and answers and 2019,

Javascript interview questions and answers series

Javascript Interview Questions and Answers - Part 1
Javascript Interview Questions and Answers - Part 2
Javascript Interview Questions and Answers - Part 3
Javascript Interview Questions and Answers - Part 4
Javascript Interview Questions and Answers - Part 5
Javascript Interview Questions and Answers - Part 6
Javascript Interview Questions and Answers - Part 7
Рекомендации по теме
Комментарии
Автор

Excellent video man!
Here is another way to solve this:

const findOddAndEvenNumbers = function (array) {
const oddNumbers = [];
const evenNumbers = [];
array.forEach((value) => (value % 2 === 1 ? oddNumbers.push(value) : evenNumbers.push(value)));
return { oddNumbers: oddNumbers, evenNumbers: evenNumbers };
}

Using this function, you only need to iterate the array once, so you reduce processing time.

renzodiaz
Автор

Great Work Brother !! Thanks for uploading such a great content you are pure soul !! and also great explanation !! just love your content brother !!

ajaykharat
Автор

Just what i wanted to see - thank you!

Indianlifestyle
Автор

god bless you brother for this awesome playlist

slideshare
Автор

Very good explanation bro. Please make these type of questions with explanation daily 2-4 videos bro.

CK-irke
Автор

brother ye `==!` kya use kiya hai pehli bar dekh raha hu

ujjvalw
Автор

what does this logic "item%2===!0" mean ?? I guess it should be "!==0"

webLinguistic
welcome to shbcf.ru