summaryrefslogtreecommitdiff
path: root/demo/script.js
diff options
context:
space:
mode:
authorJesse Morgan <jesse@jesterpm.net>2023-12-29 23:34:38 -0800
committerJesse Morgan <jesse@jesterpm.net>2023-12-29 23:34:38 -0800
commit9ea74605c9537321a35f96bf41e667c3bf02cd7a (patch)
treefb48be10d05b1f792925864bdd7da55a6035c170 /demo/script.js
parentd04b4dfa993681060d363b5ef994c1a635f3c1f9 (diff)
Checkpoint: naive JS compilation
Diffstat (limited to 'demo/script.js')
-rw-r--r--demo/script.js15
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;
+ }
+ }
+}
+