![Trending Articles on Technical and Non Technical topics](/images/trending_categories.jpeg)
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to check if an array contains integer values in JavaScript ?
We are required to write a JavaScript function that takes in an array of elements.
Our function should check whether or not the array contains an integer value.
We should return true if it does false otherwise.
Example
The code for this will be −
const arr = ["123", "", "21345", "90"]; const findInteger = (arr = []) => { const isInteger = num => { return typeof num === 'number'; }; const el = arr.find(isInteger); return !!el; }; console.log(findInteger(arr));
Output
And the output in the console will be −
false
Advertisements