javascript filter multiple values code example
Example 1: javascript filter array multiple values
let numbers = [3, 7, 2, 15, 4, 9, 21, 14];
let filteredNumbers = numbers.filter(function (currentElement) {
if (currentElement > 3 && currentElement < 17) {
return true;
}
});
console.log(filteredNumbers);
Example 2: javascript find object in array by multiple property values
let serverProposal = lobby.proposals.find( (p) => p.author == userID && p.isSubmitted == false);
Example 3: javascript select multiple values
const selected = document.querySelectorAll('#select-meal-type option:checked');
const values = Array.from(selected).map(el => el.value);