Wiki Elegant

Uncategorized

Instances of the Fibonacci Sequence

Instances of the Fibonacci Sequence Create a function that takes a number as an argument and returns n instances of the Fibonacci sequence as an array. Fibonacci numbers: F(n) = F(n-1) + F(n-2) with F(0) = 0 and F(1) = 1. So the easy explanation is: The next element is the sum of the two previous elements. If you want …

Instances of the Fibonacci Sequence Read More »

How Much is True?

How Much is True? Create a function which returns the number of true values there are in an array. Examples countTrue([true, false, false, true, false]) ➞ 2 countTrue([false, false, false, false]) ➞ 0 countTrue([]) ➞ 0 Notes Return 0 if given an empty array. All array items are of the type bool (true or false). Answer (1) const countTrue = r …

How Much is True? Read More »