summaryrefslogtreecommitdiff
path: root/graphs/js/eslint
diff options
context:
space:
mode:
authorMartial Simon <msimon_fr@hotmail.com>2025-09-15 01:08:27 +0200
committerMartial Simon <msimon_fr@hotmail.com>2025-09-15 01:08:27 +0200
commitc9b6b9a5ca082fe7c1b6f58d7713f785a9eb6a5c (patch)
tree3e4f42f93c7ae89a364e4d51fff6e5cec4e55fa9 /graphs/js/eslint
add: graphs et rushs
Diffstat (limited to 'graphs/js/eslint')
-rw-r--r--graphs/js/eslint/fibo.js31
1 files changed, 31 insertions, 0 deletions
diff --git a/graphs/js/eslint/fibo.js b/graphs/js/eslint/fibo.js
new file mode 100644
index 0000000..9b466e7
--- /dev/null
+++ b/graphs/js/eslint/fibo.js
@@ -0,0 +1,31 @@
+function fibo(n) {
+ // I'm a comment
+ if (typeof n != "number" || isNaN(n)) {
+ return -1;
+ }
+
+ if (n < 0) {
+ return -1;
+ }
+
+ if (n === 0) {
+ return 0;
+ }
+
+ let a = 1;
+
+ let b = 1;
+ let result = 1;
+
+ for (let i = 2; i < n; i++) {
+ result = a + b;
+ b = a;
+ a = result;
+ }
+
+ return result;
+}
+
+module.exports = {
+ fibo,
+};