Skip to content
Advertisement

show difference between of two price list

I have history list of product price(order by created_at) like this:

JavaScript

Now for show data in table I listed price using foreach method like this:

JavaScript

I can see true output in table but I need to show difference between of two price in the third column like this picture:

enter image description here

how do can i show difference between of two price in my list?!

Advertisement

Answer

You just need to compare the current price property to the price from the previous object in the array?

Something like this should work:

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement