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 @@ function sumFibs(num) {
|
||||
// Sum only the odd numbers and return the value
|
||||
return arrFib.reduce((acc, curr) => {
|
||||
return acc + curr * (curr % 2);
|
||||
});
|
||||
}, 0);
|
||||
}
|
||||
|
||||
// test here
|
||||
sumFibs(4);
|
||||
```
|
||||
|
||||
 [Ejecutar código](https://repl.it/@kr3at0/SumAllOddFibonacciNumbers)
|
||||
 [Ejecutar código](https://repl.it/repls/ImpassionedFineConnection)
|
||||
|
||||
### Explicación del código:
|
||||
|
||||
@@ -121,4 +121,4 @@ function sumFibs(num) {
|
||||
* Categorice la solución en una de las siguientes categorías: **Básica** , **Intermedia** y **Avanzada** . 
|
||||
* Agregue su nombre de usuario solo si ha agregado algún **contenido principal relevante** . (  **_NO_** _elimine ningún nombre de usuario existente_ )
|
||||
|
||||
> Ver  [**`Wiki Challenge Solution Template`**](http://forum.freecodecamp.com/t/algorithm-article-template/14272) para referencia.
|
||||
> Ver  [**`Wiki Challenge Solution Template`**](http://forum.freecodecamp.com/t/algorithm-article-template/14272) para referencia.
|
||||
|
Reference in New Issue
Block a user