0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

JavaScriotのfilterとsortについて

Posted at

備忘録です。

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

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?