-1
Good morning! I am taking the Santander course, and the last challenge is the famous calculation of the height of the tree of life. I have a very specific problem. Rather, it follows the statement:
Utopian trees grow in a particular way in two cycles:
each spring double its size each summer grow one meter if Laura plant a utopian tree with one meter, in late autumn, which would be its height after N cycles?
Some examples:
si N = 0, your height will be 1 meter (nothing has grown);
si N = 1, its height will be 2 meters (doubled the height in spring)
si N = 2, its height will be 3 meters (grew one meter more in summer)
si N = 3, its height will be 6 meters (doubled the height in spring next)
And so ... Write the function alturaArvoreUtopica, which uses a amount of growth cycles, and return the height resulting from the laura tree.
So, since the platform is kind of bad, I usually do the code in Codepen, test and then move to the platform in the course. My code looked like this:
function alturaArvoreUtopica (ciclos) {
var altura = 1;
if (ciclos == 0) {
altura = 1;
} else {
for (var i=1; i<=ciclos; i++) {
if (i % 2 == 0) {
altura += 1;
} else {
altura = altura*2;
}
}
return altura
}}
In Codepen the code worked well in all tests, however, when running the code on the platform appeared the following error: Expected Undefined to Equal 1.
Does anyone know what might have happened? Is it some detail I missed or should I redo the code differently?
Your question is about a third-party testing tool. Nor is it about a standardized testing tool. The question the use of this test tool should be asked to those who made the tool or who are using it as a teaching method.
– Augusto Vasques