“Array penyaringan” Kode Jawaban

filter array

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

array filter

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

filter array

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

Memfilter array dalam 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

Array penyaringan

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

Jawaban yang mirip dengan “Array penyaringan”

Pertanyaan yang mirip dengan “Array penyaringan”

Jelajahi jawaban kode populer menurut bahasa

Jelajahi bahasa kode lainnya