sum all odd fibonacci numbers
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;
}
// test here
sumFibs(4);
Also in JavaScript:
- jquery typeof undefined
- javascript onclick open url same window
- accept header json
- jquery closest
- node get value from map
- Programação web com Node e Express Beneficiando-se da stack JavaScript
- makeMany adonis js
- jquery pause n seconds
- javascript empty array
- upload image in firebase storage react web
- convert string to array js
- adding a variable to a string without using + in javascript
- react quick tutorial
- how to make a scrollable list component in react js
- install nuxt js
- convert data into json format in javascript
- onchange not working input jquery
- javascript remove diacritics
- material ui color background
- javascript iterate through a binary tree
- javascript get random integer in given range
- enzynme not support react 17
- vector
- get location from brwoser react