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) كمرجع.
|
||||
|
@ -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);
|
||||
```
|
||||
|
||||
 [运行代码](https://repl.it/@kr3at0/SumAllOddFibonacciNumbers)
|
||||
 [运行代码](https://repl.it/repls/ImpassionedFineConnection)
|
||||
|
||||
### 代码说明:
|
||||
|
||||
@ -121,4 +121,4 @@ function sumFibs(num) {
|
||||
* 将解决方案分为以下类别之一 - **基本** , **中级**和**高级** 。 
|
||||
* 如果您添加了任何**相关的主要内容,**请仅添加您的用户名。 (  **_不要_** _删除任何现有的用户名_ )
|
||||
|
||||
> 看到 [**`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)供参考。
|
||||
|
@ -92,13 +92,13 @@ As you get the next odd one, don't forget to add it to a global variable that ca
|
||||
// First, reverse the array to avoid starting acc with the first/greater number when it's even
|
||||
return arrFib.reverse().reduce((acc, curr) => {
|
||||
return acc + curr * (curr % 2);
|
||||
});
|
||||
}, 0);
|
||||
}
|
||||
|
||||
// test here
|
||||
sumFibs(4);
|
||||
|
||||
 <a href='https://repl.it/@kr3at0/SumAllOddFibonacciNumbers' target='_blank' rel='nofollow'>Run Code</a>
|
||||
 <a href='https://repl.it/repls/ImpassionedFineConnection' target='_blank' rel='nofollow'>Run Code</a>
|
||||
|
||||
### Code Explanation:
|
||||
|
||||
|
@ -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);
|
||||
```
|
||||
|
||||
 [Executar código](https://repl.it/@kr3at0/SumAllOddFibonacciNumbers)
|
||||
 [Executar código](https://repl.it/repls/ImpassionedFineConnection)
|
||||
|
||||
### Explicação do código:
|
||||
|
||||
@ -121,4 +121,4 @@ function sumFibs(num) {
|
||||
* Categorize a solução em uma das seguintes categorias - **Básica** , **Intermediária** e **Avançada** . 
|
||||
* Por favor, adicione seu nome de usuário somente se você adicionou qualquer **conteúdo principal relevante** . (  **_NÃO_** _remova nenhum nome de usuário existente_ )
|
||||
|
||||
> Vejo  [**`Wiki Challenge Solution Template`**](http://forum.freecodecamp.com/t/algorithm-article-template/14272) para referência.
|
||||
> Vejo  [**`Wiki Challenge Solution Template`**](http://forum.freecodecamp.com/t/algorithm-article-template/14272) para referência.
|
||||
|
@ -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);
|
||||
```
|
||||
|
||||
 [Код запуска](https://repl.it/@kr3at0/SumAllOddFibonacciNumbers)
|
||||
 [Код запуска](https://repl.it/repls/ImpassionedFineConnection)
|
||||
|
||||
### Код Объяснение:
|
||||
|
||||
@ -121,4 +121,4 @@ function sumFibs(num) {
|
||||
* Классифицируйте решение в одной из следующих категорий - **Basic** , **Intermediate** и **Advanced** . 
|
||||
* Пожалуйста, добавьте свое имя пользователя, только если вы добавили **соответствующее основное содержимое** . (  **_НЕ_** _удаляйте существующие имена пользователей_ )
|
||||
|
||||
> Увидеть  [**`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) для справки.
|
||||
> Увидеть  [**`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) для справки.
|
||||
|
@ -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