Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

Sum of odd Fibonacci numbers JS

  //sum-all-odd-fibonacci-numbers-in-js
function (num) {
	let a = 1;
	let b = 1;
	let sum = 1;
	while(b <= num){
		if(b % 2 == 1){
			sum += b;
		}
	let temp = b;
	b = a + b;
	a = temp;
}
if(sum ==2){
	return "Number";
}
return sum;
}
Comment

PREVIOUS NEXT
Code Example
Javascript :: check date format javascript 
Javascript :: how to loop through array of numbers in javascript 
Javascript :: innertext vs textcontent 
Javascript :: electron get exe path 
Javascript :: js maximum number value 
Javascript :: javascript check if string is valid hex color 
Javascript :: loop through javascript array 
Javascript :: regex match word inside string 
Javascript :: react detect enter key 
Javascript :: get html tag javascript 
Javascript :: check row empty array javascript 
Javascript :: how do i listen to a keypress in javascript 
Javascript :: node if file exists 
Javascript :: javascript get ip 
Javascript :: js form serialize 
Javascript :: js how to get data fetch 
Javascript :: hex to rgba in js 
Javascript :: count no of punctuation in string in js 
Javascript :: fetch api cors 
Javascript :: angular serve 
Javascript :: pagination in strapi 
Javascript :: on click jqueyr 
Javascript :: clear input field jquery 
Javascript :: hide component on click vue 
Javascript :: toaster cdn 
Javascript :: scroll event js 
Javascript :: react save to local storage 
Javascript :: TypeError: Object of type uint32 is not JSON serializable 
Javascript :: javascript detect when number of elements change 
Javascript :: iterate through list javascript 
ADD CONTENT
Topic
Content
Source link
Name
3+9 =