From f49cd7df9684a5e74afde9e3b684599b6ab9b98b Mon Sep 17 00:00:00 2001 From: NetMan <13informatyka14@gmail.com> Date: Thu, 11 Jan 2024 21:39:13 +0100 Subject: [PATCH] Passed tests 8 and 9 from exercise 10 --- 10_fibonacci/fibonacci.js | 6 ++++++ 10_fibonacci/fibonacci.spec.js | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/10_fibonacci/fibonacci.js b/10_fibonacci/fibonacci.js index 38f2021..91e3c1a 100644 --- a/10_fibonacci/fibonacci.js +++ b/10_fibonacci/fibonacci.js @@ -1,4 +1,10 @@ const fibonacci = function(number) { + if (number == 0) { + return 0; + } + if (number < 0) { + return "OOPS"; + } let a = 1, b = 1; let sum = a; for (let i = 0; diff --git a/10_fibonacci/fibonacci.spec.js b/10_fibonacci/fibonacci.spec.js index 6601caf..ef1f3c8 100644 --- a/10_fibonacci/fibonacci.spec.js +++ b/10_fibonacci/fibonacci.spec.js @@ -22,10 +22,10 @@ describe('fibonacci', () => { test('2nd fibonacci number is 1', () => { expect(fibonacci(2)).toBe(1); }); - test.skip('0th fibonacci number is 0', () => { + test('0th fibonacci number is 0', () => { expect(fibonacci(0)).toBe(0); }); - test.skip('doesn\'t accept negatives', () => { + test('doesn\'t accept negatives', () => { expect(fibonacci(-25)).toBe("OOPS"); }); test.skip('DOES accept strings', () => {