diff options
Diffstat (limited to 'demo/script.js')
-rw-r--r-- | demo/script.js | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/demo/script.js b/demo/script.js new file mode 100644 index 0000000..c829cc0 --- /dev/null +++ b/demo/script.js @@ -0,0 +1,15 @@ + +function lowest_price() { + const offers = [{ id: 1, price: 2.01}, { id: 2, price: 2.99 }]; + + let min_price = null; + let best_offer = null; + + for (const offer of offers) { + if (min_price === null || offer.price < min_price) { + min_price = offer.price; + best_offer = offer; + } + } +} + |