added explicit conversion to number for fibonacci solution
This commit is contained in:
parent
4a03e410bf
commit
80ca665767
|
@ -1,4 +1,13 @@
|
||||||
const fibonacci = function(count) {
|
const fibonacci = function(countArg) {
|
||||||
|
// checks argument's type and makes sure we use
|
||||||
|
// a number throughout rest of function.
|
||||||
|
let count
|
||||||
|
if (typeof countArg !== 'number') {
|
||||||
|
count = parseInt(countArg)
|
||||||
|
} else {
|
||||||
|
count = countArg
|
||||||
|
}
|
||||||
|
|
||||||
if (count < 0) return "OOPS";
|
if (count < 0) return "OOPS";
|
||||||
if (count == 0) return 0;
|
if (count == 0) return 0;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue