Fix "hint" code not working for the challenge: "Sum All Odd Fibonacci Numbers" (#28676)
* Fix code not passing on challenge tests The code was not passing the challenge tests because we must sum only odd numbers. Cince we didn't provided an initial value for reduce, it would use the first element of the array, and if it was an odd number, it would skip our validation and add it to the final result. [https://www.freecodecamp.org/forum/t/sum-all-odd-fibonacci-numbers-solution-not-passing-all-tests/236058](https://www.freecodecamp.org/forum/t/sum-all-odd-fibonacci-numbers-solution-not-passing-all-tests/236058) * Same English fixed for Arabic * Same English fix for Chinese * Same English fix for Portuguese * Same English fix for Russian * Same English fix for Spanish
This commit is contained in:
@@ -93,14 +93,14 @@ localeTitle: Sum All Odd Fibonacci Numbers
|
||||
// Sum only the odd numbers and return the value
|
||||
return arrFib.reduce((acc, curr) => {
|
||||
return acc + curr * (curr % 2);
|
||||
});
|
||||
}, 0);
|
||||
}
|
||||
|
||||
// test here
|
||||
sumFibs(4);
|
||||
`
|
||||
|
||||
 [تشغيل الكود](https://repl.it/@kr3at0/SumAllOddFibonacciNumbers)
|
||||
 [تشغيل الكود](https://repl.it/repls/ImpassionedFineConnection)
|
||||
|
||||
### شرح الشفرة:
|
||||
|
||||
@@ -121,4 +121,4 @@ localeTitle: Sum All Odd Fibonacci Numbers
|
||||
* تصنيف الحل في واحدة من الفئات التالية - **الأساسي** **والمتوسط** **والمتقدم** . 
|
||||
* الرجاء إضافة اسم المستخدم الخاص بك فقط إذا قمت بإضافة أي **محتويات رئيسية ذات صلة** . (  **_لا_** _تزيل أي أسماء مستخدمين حالية_ )
|
||||
|
||||
> نرى  [**`Wiki Challenge Solution Template`**](http://forum.freecodecamp.com/t/algorithm-article-template/14272) كمرجع.
|
||||
> نرى  [**`Wiki Challenge Solution Template`**](http://forum.freecodecamp.com/t/algorithm-article-template/14272) كمرجع.
|
||||
|
Reference in New Issue
Block a user