0
Help us understand the problem. What are the problem?

More than 1 year has passed since last update.

Organization

JavaScriotのfilterとsortについて

備忘録です。

const satoru = {
  age: 38,
  name: 'tanaka'
};

const ken = {
  age: 34,
  name: 'yamada'
};

const nozomi = {
  age: 30,
  name: 'koyama'
};

const users = [ken, nozomi, satoru];

const ages = users.map(user => {
  const tall = user.age*5; // 年齢を5倍した数を、仮に身長の数値に見立てただけで、意味はありません。
  return tall;
});

const segatakaihito = ages.filter(tall => tall > 172)

console.log(ages.sort().reverse()); //並び替え、背が低い順
console.log(segatakaihito);

結果

(3) [190,170,150]
(1) [190]
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
0
Help us understand the problem. What are the problem?