From 9ea74605c9537321a35f96bf41e667c3bf02cd7a Mon Sep 17 00:00:00 2001 From: Jesse Morgan Date: Fri, 29 Dec 2023 23:34:38 -0800 Subject: Checkpoint: naive JS compilation --- demo/script.js | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 demo/script.js (limited to 'demo') 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; + } + } +} + -- cgit v1.2.3