New to javascript and trying to learn! I am trying to map through two array of objects, and if a certain property matches, pull in specific information into an array.
let result;
let arrNames = [{
name: "A"
}, {
name: "B"
}, {
name: "C"
}]
let arrInfo = [{
name: "A",
info: "AAA"
}, {
name: "B",
info: "BBB"
}, {
name: "C",
info: "ccc"
}]
If arrNames.name == arrInfo.name, I would like result to equal arrInfo.info.
What I've tried:
arrNames.map(x => {
if(arrNames.name == arrInfo.name){
result=arrInfo.info
}
^ This obviously doesn't work -- but I'm wondering if Assign or Filter would be appropriate.
Thanks in advance for your help (apologies that this is probably a dupe)!