我需要以这样一种方式减少数组 1:数组 1 应该只包含那些“friendlyName”与数组 2 的值匹配的项目。
我尝试了以下代码,但没有奏效。任何人都可以帮助我-
arrray2.map(asdf => {
console.log("asdf",asdf)
console.log("dum",array1)
array1.filter(dat => dat.friendlyName.includes(asdf)).map(d => (
console.log( "d",d)
))
})
数组 1 -
renderTaskQueues
(3) [{…}, {…}, {…}]
0:
accountSid: "AC90e9fc43df2675a1a2de215c0e78fc74"
assignmentActivityName: null
friendlyName: "CUSTOMER_SERVICE_SP"
__proto__: Object
1:
accountSid: "AC90e9fc43df2675a1a2de215c0e78fc74"
assignmentActivityName: "Offline"
friendlyName: "CUSTOMER_SERVICE_EN"
__proto__: Object
2:
accountSid: "AC90e9fc43df2675a1a2de215c0e78fc74"
friendlyName: "Survey"
__proto__: Object
length: 3
__proto__: Array(0)
数组 2 -
agentQueuesArray
(2) ["Customer_Service_EN", "Customer_Service_SP"]
0: "Customer_Service_EN"
1: "Customer_Service_SP"
length: 2
__proto__: Array(0)
答案 0 :(得分:0)
不匹配,因为大小写不同。你可以这样做:
arrray2.map(asdf => {
console.log("asdf",asdf)
console.log("dum",array1)
array1.filter(dat => dat.friendlyName.toUpperCase() === asdf.toUpperCase()).map(d => (
console.log( "d",d)
))
})