JavaScript program that return the sum of all odd Fibonacci numbers that are less than or equal to n
###### Posted by SceDev
Last Updated: March 28, 2024

Write a JavaScript program that return the sum of all odd Fibonacci numbers that are less than or equal to n.

Code:

```function sumOfOddFibonacci(num) {
let prev = 0, curr = 1, result = 0;
while (curr <= num) {
if (curr % 2 !== 0) {
result += curr;
}
curr += prev;
prev = curr - prev;
}
return result;
}

var result = sumOfOddFibonacci(10)

console.log(result);
```
###### Java program that uses a loop to compute the sum of all odd digits of an input. (For example, if the input is 32677, the sum would be 3 + 7 + 7 = 17.)
Samath | Apr 03, 2022
###### Display the first 10 Fibonacci numbers in C++
Samath | Nov 02, 2014
###### JavaScript program that return an array containing only even numbers between 1 and n
SceDev | Feb 17, 2024
###### C program that determines if a number is equal to zero
Samath | Nov 07, 2014
###### Sum of two values in C
Samath | Nov 09, 2014
###### C Program to find sum of two numbers
Samath | Jan 02, 2017
###### C++ Calculate the sum from 1 to 100
Samath | Jan 05, 2017
###### C Program to generate the Fibonacci Series starting from any two numbers
Samath | Jan 02, 2017
###### C++ Fibonacci Number Sequence using Recursion
Samath | Jan 05, 2017
###### JavaScript program that returns the nth entry in the Fibonacci sequence
SceDev | Feb 27, 2024
###### C program that receives a positive float number and divides it by two until the result is less than or equal to zero
Samath | Jun 12, 2015
###### Write a function in C called RectArea() that returns an integer value equal to the area of the given rectangle
Samath | May 04, 2016
###### Java program that read a sequence of integer inputs and print the number of even and odd inputs.
Samath | Apr 03, 2022
###### Write a C++ program that find the sum of all even numbers between 1 and 30 excluding 6, 8, 24 and 28
Samath | Nov 02, 2014