commit a3f4ca664f7883bcce24448ca3b9876f117a3902 Author: didier amyot Date: Thu Nov 30 12:27:37 2023 -0500 Added module example diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..485dee6 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.idea diff --git a/exo-recapitulatif/index.html b/exo-recapitulatif/index.html new file mode 100644 index 0000000..0545bb6 --- /dev/null +++ b/exo-recapitulatif/index.html @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/exo-recapitulatif/script.js b/exo-recapitulatif/script.js new file mode 100644 index 0000000..125bc46 --- /dev/null +++ b/exo-recapitulatif/script.js @@ -0,0 +1,11 @@ + +export function toto(){ + console.log("say toto"); +} + +export function hello(){ + console.log("say hello"); +} + +document.querySelector('#foo').addEventListener('click', toto); +document.querySelector('#foo').addEventListener('click', hello); \ No newline at end of file diff --git a/modules-examples/stats.js b/modules-examples/stats.js new file mode 100644 index 0000000..81c07fb --- /dev/null +++ b/modules-examples/stats.js @@ -0,0 +1,28 @@ +export function average(lst){ + if(lst.length < 1){ + return NaN; + } + let sum = 0; + let n = 0; + for(const e of lst){ + sum += e; + n += 1; + } + return sum / n; +} + + +export function std(lst){ + if(lst.length < 1){ + return NaN; + } + let sum = 0; + let sum2 = 0; + let n = 0; + for(const e of lst){ + sum += e; + sum2 += e * e; + n += 1; + } + return Math.sqrt( sum2 / n - Math.pow(sum / n, 2)); +} \ No newline at end of file