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
Introduction The Observer Pattern is a design pattern used to manage and notify multiple objects…
Memory management is like housekeeping for your program—it ensures that your application runs smoothly without…
JavaScript has been a developer’s best friend for years, powering everything from simple websites to…
In the digital age, web development plays a crucial role in shaping how individuals interact…
Introduction Handling large amounts of data efficiently can be a challenge for developers, especially when…