“Função de filtro” Respostas de código

Filtre a matriz JavaScript

var words = ['spray', 'limit', 'elite', 'exuberant', 'destruction', 'present'];

const result = words.filter(word => word.length > 6);

console.log(result);
White Browed Owl

filtro na função de matriz

const persons = [
  {name:"Shirshak",gender:"male"},
  {name:"Amelia",gender:"female"},
  {name:"Amand",gender:"male"}
]
//filter return all objects in array
let male = persons.filter(function(person){
return person.gender==='male'
})
console.log(male) //[{name:"Shirshak",gender:"male"},{name:"Amand",gender:"male"}]

//find return first object that match condition
let female = persons.find(function(person){
return person.gender==='female'
})
Sab Tech

filtro de matriz

const words = ['spray', 'limit', 'elite', 'exuberant', 'destruction', 'present'];

const result = words.filter(word => word.length > 6);

console.log(result);
// expected output: Array ["exuberant", "destruction", "present"]
Difficult Dolphin

Como a função filtro () funciona JavaScript

const arr = [1, 2, 3, 4, 5, 6, 7, 8, 9];

const filter = arr.filter((number) => number > 5);
console.log(filter); // [6, 7, 8, 9]
DCmax1k

filtro de matriz JavaScript

var numbers = [1, 3, 6, 8, 11];

var lucky = numbers.filter(function(number) {
  return number > 7;
});

// [ 8, 11 ]
Two Toed Tree Sloth

Função de filtro

# filter function
l1=[10,20,30,40,50,60,70,80]
l2= [i for i in filter(lambda x:x>30,l1)]
print(l2)


# [40, 50, 60, 70, 80]
# filter takes a function and a collection. It returns a collection of every item for which the function returned True.
Impossible Impala

Respostas semelhantes a “Função de filtro”

Perguntas semelhantes a “Função de filtro”

Mais respostas relacionadas para “Função de filtro” em Python

Procure respostas de código populares por idioma

Procurar outros idiomas de código