Chapter 10: Working with Workers samples

This commit is contained in:
Beth Griggs
2020-08-31 01:12:46 +01:00
parent 575ab40a00
commit 52d632f0d2
3 changed files with 66 additions and 0 deletions
+14
View File
@@ -0,0 +1,14 @@
const n = 10;
// Fibonacci calculator
const fibonacci = (n) => {
let a = 0, b = 1, next = 1, i = 2;
for (i; i <= n; i++) {
next = a + b;
a = b;
b = next;
}
console.log(`The Fibonacci number at position ${n} is ${next}`);
};
fibonacci(n);
console.log("...");