“Filterarrays” Code-Antworten

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

Filterarray

const filteredArray = array.filter(element => element.id != id))
Didi Abel

Array -Filter

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

const result = words.filter(word => word.length > 5)

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

array filter
Santhosh Sivan S

Filtern Sie ein Array in JavaScript

function bouncer(arr) {
  let newArray = [];
  for (let i = 0; i < arr.length; i++) {
    if (arr[i]) newArray.push(arr[i]);
  }
  return newArray;
}
Angry Alpaca

Filterarrays

function filter(array, test) {
  let passed = [];
  for (let element of array) {
    if (test(element)) {
      passed.push(element);
    }
  }
  return passed;
}

console.log(filter(SCRIPTS, script => script.living));
// → [{name: "Adlam", …}, …]
Xanthous Xenomorph

Ähnliche Antworten wie “Filterarrays”

Fragen ähnlich wie “Filterarrays”

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen