I recently started diving into the world of programming and I'm facing a challenge. I have an Array consisting of 4 items (you can view the Array in the Code section below), each item having its own id (1-4).
What I aim to achieve is creating a method that executes specific code for each item in the Array. My initial approach was to use if statements to check for the individual ids of each item, but I'm not sure how to proceed.
If anyone has a more efficient solution, I'd greatly appreciate your input.
Best regards, John.
{ id: 1, name: 'BMW', price: 250, quantity: ''},
{ id: 2, name: 'Google', price: 110, quantity: ''},
{ id: 3, name: 'Apple', price: 1000, quantity: ''},
{ id: 4, name: 'Twitter', price: 50, quantity: ''}