“Фильтрация в JavaScript” Ответ

Фильтр 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

Фильтруя массив JavaScript

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

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

console.log(result);
White Browed Owl

Фильтр 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

Фильтр в 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

JavaScript Filter

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

Фильтрация в 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

Ответы похожие на “Фильтрация в JavaScript”

Вопросы похожие на “Фильтрация в JavaScript”

Больше похожих ответов на “Фильтрация в JavaScript” по JavaScript

Смотреть популярные ответы по языку

Смотреть другие языки программирования