“Filtrowanie w JavaScript” Kod odpowiedzi

Filtr JavaScript

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

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

console.log(result);

//OUTPUT: ['spray', 'limit', 'elite']
Moscode

Filtruj tablicę JavaScript

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

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

console.log(result);
White Browed Owl

Filtr 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]

or 

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"]
Aggressive Albatross

Filtr w JS

const filterThisArray = ["a","b","c","d","e"] 
console.log(filterThisArray) // Array(5) [ "a","b","c","d","e" ]

const filteredThatArray = filterThisArray.filter((item) => item!=="e")
console.log(filteredThatArray) // Array(4) [ "a","b","c","d" ]
D@RK$T@R

Filtr JavaScript

const myNum = [2,3,4,5,6,7,8,9,10];
//using filter gives us a new array
const divisibleBy3 = myNum.filter(eachNum => eachNum%3==0); 
console.log(divisibleBy3); //output:[3,6,9]
Aggressive Antelope

Filtrowanie w JavaScript

  //filter numbers divisible by 2 or any other digit using modulo operator; %
  
  const figures = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
  const divisibleByTwo = figures.filter((num) => {
    return num % 2 === 0;
  });
  console.log(divisibleByTwo);
Fierce Fox

Odpowiedzi podobne do “Filtrowanie w JavaScript”

Pytania podobne do “Filtrowanie w JavaScript”

Więcej pokrewnych odpowiedzi na “Filtrowanie w JavaScript” w JavaScript

Przeglądaj popularne odpowiedzi na kod według języka

Przeglądaj inne języki kodu