“Filterfunktion” Code-Antworten

Filter JavaScript Array

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

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

console.log(result);
White Browed Owl

Filter in der Array -Funktion

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

Array -Filter

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

Wie die Funktion filter () funktioniert 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

JavaScript -Array -Filter

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

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

// [ 8, 11 ]
Two Toed Tree Sloth

Filterfunktion

# 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

Ähnliche Antworten wie “Filterfunktion”

Fragen ähnlich wie “Filterfunktion”

Weitere verwandte Antworten zu “Filterfunktion” auf Python

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen