Filtering arrays in javascript
The Array filter method is used to check against a given condition.
Task: print out all multiples of 3 in the given array:
let x = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15];
Answer:
let x = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15];
mulValue = (val) => {
return val % 3 === 0;
}
let result = x.filter(mulValue);
alert(result) // 3,6,9,12,15
The South Korean government announced on Monday that it had temporarily halted new downloads of…
As a software developer, choosing the right programming language for software development can be a…
A server farm, also known as a server cluster or data center, is a collection…
Pakistan's mobile and broadband internet speeds rank in the bottom 10 percent globally, according to…
React Native is a popular framework for building cross-platform mobile applications using JavaScript and React.…
Google is not only passionate about developing innovative apps and services but also about finding…