Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

how to get number of a specific element of an array

// Let has local scope
let array = [1, 2, 3, 5, 2, 8, 9, 2]

// Functional filter with an Arrow function
array.filter(x => x === 2).length  // -> 3
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #number #specific #element #array
ADD COMMENT
Topic
Name
5+2 =