How can I get the Fibonacci sequence numbers all before the parameter and includes the parameter

function sumFibs(num) {
let result = 0;
const fibbNums = ((num, arr = [0, 1]) => {
  while (num > 1) {
    let [nextToLast, last] = arr.slice(-2);
    arr.push(nextToLast + last);

  return arr

for (let i = 0; i <= num; i++) {
  if (fibbNums(num)[i] % 2 !== 0) {
    result += fibbNums(num)[i]
// console.log(fibbNums(num))

  **Your browser information:**

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.88 Safari/537.36

Challenge: Sum All Odd Fibonacci Numbers

Link to the challenge:

Hello there.

Do you have a question?

If so, please edit your post to include it in the Tell us what’s happening section.

Learning to describe problems is hard, but it is an important part of learning how to code.

Also, the more information you give us, the more likely we are to be able to help.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.