Js data processing, how to get the array in the diagram according to the order of fields in type

clipboard.png

type

clipboard.png

Mar.30,2021

var type = ['a', 'b', 'c'];
var list = [
    {name: 'a', age:21},
    {name: 'd', age: 22},
    {name: 'c', age: 33}
]
list.filter((item)=> {
    return type.includes(item.name);
})

if it's helpful, please take it. Thank you

=

var type = ['a', 'b', 'c'];
var list = [
    {name: 'd', age: 22},
    {name: 'c', age: 33},
    {name: 'a', age: 11}    
]
const result = [];
type.forEach((t) =>{
    list.forEach((item) =>{
        if(t === item.name) {
            result.push(item);
        }
    })
})

  

create an empty array, loop through type, and then traverse list, to compare type [I] with list [nane], and push to the new array

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e4c1a7-4d224.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e4c1a7-4d224.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?