Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

js how to filter only real numbers from decimals

const arr = [3, 4.5, 6, 1.1]
const integers = arr.filter(n => Number.isInteger(n));
console.log(integers)
// output [3, 6]
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #js #filter #real #numbers #decimals
ADD COMMENT
Topic
Name
8+8 =