Hello!
Assuming I have two arrays as below. How can I, in the easiest way, without using a for loop or similar check if the player owns a company that is part of the Top companies?
Been going nuts for two hours trying to figure this out. I've been going over includes, contains, filter and forEach trying to make this go together, granted, I only slept 3 hours last night and I've been in front of the screen all day, so my brain is a wee bit mushy at this point.
But yes, this is where I am stuck at the moment... And I don't want to use a for loop as I know how to do that already, I want to learn some Array functions. And I really feel like using a combination of filter, foreach but what if there is a super easy way, perhaps using the find function would work. But please, do give me a guideline at this point 🙂
Assuming I have two arrays as below. How can I, in the easiest way, without using a for loop or similar check if the player owns a company that is part of the Top companies?
Been going nuts for two hours trying to figure this out. I've been going over includes, contains, filter and forEach trying to make this go together, granted, I only slept 3 hours last night and I've been in front of the screen all day, so my brain is a wee bit mushy at this point.
But yes, this is where I am stuck at the moment... And I don't want to use a for loop as I know how to do that already, I want to learn some Array functions. And I really feel like using a combination of filter, foreach but what if there is a super easy way, perhaps using the find function would work. But please, do give me a guideline at this point 🙂
JavaScript:
OwnedCompanies = [
{ name: "SoftLink",
worth: 2.1,
},
{ name: "SwindlerCo",
worth: 1.6,
},
];
ExistingCompanies = [
{ name: "SoftLink",
worth: 2.1,
},
{ name: "Binghoo",
worth: 1.6,
},
{ name: "DevCo",
worth: 1.1,
},
{ name: "SwindlerCo",
worth: 1.9,
},
{ name: "Gologolo",
worth: 3.1,
},
{ name: "Yahoe",
worth: 3.3,
},
];