I am trying to achieve that, fruits is checked in onTruck to find the existing keys, then push to a new array. Since they are different length, I am stuck on how to loop them.
var fruits = ['apple', 'orange', 'banana']
var onTruck = {
'apple': 100,
'orange': 200,
'banana': 500,
'pineapple': 5,
'mango': 'empty'
}
let arr = []
Object.keys(onTruck).forEach((e, i) => {
console.log(e === fruit[]) <- Need to loop fruit
arr.push[...]
})
// OUTPUT:
arr = [['apple', '100'],['orange', '200'], ['banana', '500'] ]