## Where communities thrive

• Join over 1.5M+ people
• Join over 100K+ communities
• Free without limits
##### Activity
David Petrey
@davidpetrey
hint
CamperBot
@camperbot

hint [7/7]

## Code Solution:

function sumFibs(num) {
var prevNumber = 0;
var currNumber = 1;
var result = 0;
while (currNumber <= num) {
if (currNumber % 2 !== 0) {
result += currNumber;
}
var added = currNumber + prevNumber;
prevNumber = currNumber;
}

return result;
}

# Code Explanation:

• Create a variable to keep record of the current and previous numbers along with the result that will be returned.
• Use a while loop to make sure we do not go over the number given as parameter.
• We use the modulo operand to check if the current number is odd or even. If even add it to the result.
• Complete the Fibonacci circle by rotating getting the next number and swapping values after.
• Return the result.

# Credits:

If you found this page useful, you can give thanks by copying and pasting this on the main chat: Thanks @Rafase282

type hint for next hint :pencil: [Contribute at the FCC Wiki]

Kira Hartlage
@kirakirakira
hint
CamperBot
@camperbot

hint [1/7]

## ## :construction: After this are possible spoiler hints.

Make sure you've tried to hard to solve it yourself before proceeding. :construction:

type hint for next hint :pencil: [Contribute at the FCC Wiki]

Kira Hartlage
@kirakirakira
hint
CamperBot
@camperbot

hint [2/7]

## # Explanation:

You will need to gather all the Fibonacci numbers and then check for the odd ones. Once you get the odd ones then you will add them all. The last number should be the number given as a parameter if it actually happens to be an off Fibonacci number.

type hint for next hint :pencil: [Contribute at the FCC Wiki]

Kira Hartlage
@kirakirakira
hint
CamperBot
@camperbot

hint [3/7]

## Hint: 1

To get the next number of the series, you need to add the current one to the previous and that will give you the next one.

type hint for next hint :pencil: [Contribute at the FCC Wiki]

Kira Hartlage
@kirakirakira
hint
CamperBot
@camperbot

hint [4/7]

## Hint: 2

To check if a number is even all you have to check is if that number % 2 == 0.

type hint for next hint :pencil: [Contribute at the FCC Wiki]

Kira Hartlage
@kirakirakira
hint
CamperBot
@camperbot

hint [5/7]

## Hint: 3

As you get the next odd one, don't forget to add it to a global variable that can be returned at the end. result += currNumber; Will do the trick.

type hint for next hint :pencil: [Contribute at the FCC Wiki]

Kira Hartlage
@kirakirakira
hint
CamperBot
@camperbot

hint [6/7]

type hint for next hint :pencil: [Contribute at the FCC Wiki]

Kira Hartlage
@kirakirakira
hint
CamperBot
@camperbot

hint [7/7]

## Code Solution:

function sumFibs(num) {
var prevNumber = 0;
var currNumber = 1;
var result = 0;
while (currNumber <= num) {
if (currNumber % 2 !== 0) {
result += currNumber;
}
var added = currNumber + prevNumber;
prevNumber = currNumber;
}

return result;
}

# Code Explanation:

• Create a variable to keep record of the current and previous numbers along with the result that will be returned.
• Use a while loop to make sure we do not go over the number given as parameter.
• We use the modulo operand to check if the current number is odd or even. If even add it to the result.
• Complete the Fibonacci circle by rotating getting the next number and swapping values after.
• Return the result.

# Credits:

If you found this page useful, you can give thanks by copying and pasting this on the main chat: Thanks @Rafase282

type hint for next hint :pencil: [Contribute at the FCC Wiki]

Patrick
@JohnnyMarcone
hint
CamperBot
@camperbot

hint [1/7]

## ## :construction: After this are possible spoiler hints.

Make sure you've tried to hard to solve it yourself before proceeding. :construction:

type hint for next hint :pencil: [Contribute at the FCC Wiki]

Patrick
@JohnnyMarcone
hint
CamperBot
@camperbot

hint [2/7]

## # Explanation:

You will need to gather all the Fibonacci numbers and then check for the odd ones. Once you get the odd ones then you will add them all. The last number should be the number given as a parameter if it actually happens to be an off Fibonacci number.

type hint for next hint :pencil: [Contribute at the FCC Wiki]

Patrick
@JohnnyMarcone
hint
CamperBot
@camperbot

hint [3/7]

## Hint: 1

To get the next number of the series, you need to add the current one to the previous and that will give you the next one.

type hint for next hint :pencil: [Contribute at the FCC Wiki]

rocketrocketrocketship
@rocketrocketrocketship
hint
CamperBot
@camperbot

hint [1/7]

## ## :construction: After this are possible spoiler hints.

Make sure you've tried to hard to solve it yourself before proceeding. :construction:

type hint for next hint :pencil: [Contribute at the FCC Wiki]

hint [2/7]

## # Explanation:

You will need to gather all the Fibonacci numbers and then check for the odd ones. Once you get the odd ones then you will add them all. The last number should be the number given as a parameter if it actually happens to be an off Fibonacci number.

type hint for next hint :pencil: [Contribute at the FCC Wiki]

rocketrocketrocketship
@rocketrocketrocketship
hint
hint
CamperBot
@camperbot

hint [3/7]

## Hint: 1

To get the next number of the series, you need to add the current one to the previous and that will give you the next one.

type hint for next hint :pencil: [Contribute at the FCC Wiki]

rocketrocketrocketship
@rocketrocketrocketship
hint
CamperBot
@camperbot

hint [4/7]

## Hint: 2

To check if a number is even all you have to check is if that number % 2 == 0.

type hint for next hint :pencil: [Contribute at the FCC Wiki]

rocketrocketrocketship
@rocketrocketrocketship
hint
CamperBot
@camperbot

hint [5/7]

## Hint: 3

As you get the next odd one, don't forget to add it to a global variable that can be returned at the end. result += currNumber; Will do the trick.

type hint for next hint :pencil: [Contribute at the FCC Wiki]

rocketrocketrocketship
@rocketrocketrocketship
hint
CamperBot
@camperbot

hint [6/7]

type hint for next hint :pencil: [Contribute at the FCC Wiki]

rocketrocketrocketship
@rocketrocketrocketship
hint
CamperBot
@camperbot

hint [7/7]

## Code Solution:

function sumFibs(num) {
var prevNumber = 0;
var currNumber = 1;
var result = 0;
while (currNumber <= num) {
if (currNumber % 2 !== 0) {
result += currNumber;
}

currNumber += prevNumber;
prevNumber = currNumber - prevNumber;
}

return result;
}

# Code Explanation:

• Create a variable to keep record of the current and previous numbers along with the result that will be returned.
• Use a while loop to make sure we do not go over the number given as parameter.
• We use the modulo operand to check if the current number is odd or even. If even add it to the result.
• Complete the Fibonacci circle by rotating getting the next number and swapping values after.
• Return the result.

# Credits:

If you found this page useful, you can give thanks by copying and pasting this on the main chat: Thanks @Rafase282 @d3ddd

type hint for next hint :pencil: [Contribute at the FCC Wiki]

@snovos
hint
CamperBot
@camperbot

hint [1/8]

## ## :construction: After this are possible spoiler hints.

Make sure you've tried to hard to solve it yourself before proceeding. :construction:

type hint for next hint :pencil: [Contribute at the FCC Wiki]

ziming
@ziming
hint
CamperBot
@camperbot

hint [1/8]

## ## :construction: After this are possible spoiler hints.

Make sure you've tried to hard to solve it yourself before proceeding. :construction:

type hint for next hint :pencil: [Contribute at the FCC Wiki]

ziming
@ziming
hint
CamperBot
@camperbot

hint [2/8]

## # Explanation:

You will need to gather all the Fibonacci numbers and then check for the odd ones. Once you get the odd ones then you will add them all. The last number should be the number given as a parameter if it actually happens to be an off Fibonacci number.

type hint for next hint :pencil: [Contribute at the FCC Wiki]

ziming
@ziming
hint
CamperBot
@camperbot

hint [3/8]

## Hint: 1

To get the next number of the series, you need to add the current one to the previous and that will give you the next one.

type hint for next hint :pencil: [Contribute at the FCC Wiki]

ziming
@ziming
hint
CamperBot
@camperbot

hint [4/8]

## Hint: 2

To check if a number is even all you have to check is if that number % 2 == 0.

type hint for next hint :pencil: [Contribute at the FCC Wiki]

ziming
@ziming
hint
CamperBot
@camperbot

hint [5/8]

## Hint: 3

As you get the next odd one, don't forget to add it to a global variable that can be returned at the end. result += currNumber; Will do the trick.

type hint for next hint :pencil: [Contribute at the FCC Wiki]

ziming
@ziming
hint
CamperBot
@camperbot

hint [6/8]

type hint for next hint :pencil: [Contribute at the FCC Wiki]