Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function solve(...args) {
- const localStoreStock = args[0];
- const orderedStock = args[1];
- const products = {};
- localStoreStock.forEach((element, index) => {
- if (index % 2 === 0) {
- products[element] = Number(localStoreStock[index + 1]);
- }
- });
- orderedStock.forEach((element, index) => {
- if (products[element] !== undefined) {
- products[element] += Number(orderedStock[index + 1]);
- } else if (index % 2 === 0) {
- products[element] = Number(orderedStock[index + 1]);
- }
- });
- Object.keys(products).map((element) => console.log(`${element} -> ${products[element]}`));
- }
Add Comment
Please, Sign In to add comment