From ec72ed57b91bee8f762a6ca9413f2cc5e9c77bb8 Mon Sep 17 00:00:00 2001 From: Geir Okkenhaug Jerstad Date: Mon, 26 Aug 2024 14:39:13 +0200 Subject: [PATCH] some more of eloquent datastructures --- MVC/intro.html | 42 ++++++++++++++++++++------- eloquentjavascript/data_structures.js | 20 ++++++++++++- 2 files changed, 51 insertions(+), 11 deletions(-) diff --git a/MVC/intro.html b/MVC/intro.html index 272886d..f92a8c9 100644 --- a/MVC/intro.html +++ b/MVC/intro.html @@ -1,42 +1,64 @@ + Intro +
Hei jeg heter
-
...her kommer et navn
+
...her kommer et navn
Jeg bor i
-
..her kommer et sted
+
..her kommer et sted
Min favorittmat er
-
...her kommer en matrett
+
...her kommer en matrett
+ Navn: + Sted: + Mat: + \ No newline at end of file diff --git a/eloquentjavascript/data_structures.js b/eloquentjavascript/data_structures.js index 58e68b3..67111a0 100644 --- a/eloquentjavascript/data_structures.js +++ b/eloquentjavascript/data_structures.js @@ -113,4 +113,22 @@ function phi(table) { (table[1] + table[3]) * (table[0] + table[2])); }; -// console.log(phi([76, 9, 4, 1])); +function journalEvents(journal){ + let events = []; + for (let entry of journal){ + for (let event of entry.events){ + if (!events.includes(event)){ + events.push(event); + } + } + } + return events; +} +console.log(journalEvents(JOURNAL)); + +for (let event of journalEvents(JOURNAL)){ + let correlation = phi(tableFor(event, JOURNAL)); + if (correlation > 0.1 || correlation < -0.1){ + console.log(event + ":", correlation) + } +}