我試圖過濾這個數組來獲取id並將字符串轉換爲數字。我想使用過濾器和地圖?想知道如何儘可能清楚。如何在數組上使用array.filter + map
var pets = [
{ id: '1', name: 'rupert', readyForHome: 'No', age: 12, personality: ['friendly', 'lazy', 'loving']},
{ id: '2', name: 'mrs fluffy', readyForHome: 'Yes', age: 2, personality: ['affectionate', 'playful', 'shy']},
{ id: '3', name: 'tabitha', readyForHome: 'Yes', age: 4, personality: ['aggressive', 'independent']},
{ id: '4', name: 'lily', readyForHome: 'No', age: 8, personality: ['friendly', 'playful', 'mischievous']},
];
請添加搜索參數,輸出和你試過了什麼。您也可以在這裏看看:[mcve] –