function countdown(n) {
if (n < 1) {
return [x];
} else {
const arr = countdown(n - 1);
arr.unshift(n);
return arr;
}
}
что здесь происходит?
function countdown(n) {
if (n < 1) {
return [x];
} else {
const arr = countdown(n - 1);
arr.unshift(n);
return arr;
}
}
что здесь происходит?
Please use the Ask for Help button so we get a link to the challenge. Thanks
Какую кнопку я не совсем понимаю вас ?..
The one that says ‘Ask for Help’
Что то я на этом форуме так и не чего и не понял как тут вопросы решаются не известно для меня)
I’m not sure what you are asking. What parts of that code are confusing you? What is the link to the challenge?
Ответ я так и не получил,разъяснять тут не кто не умеет.
You never answered my question.
It helps if you interact with us.
There is so much you could ask about recursion that you really need to narrow it down for us.
мне не понятна форма записи откуда это берется и для чего const arr = countdown(n - 1);
countdown()
returns an array. const arr = countdown(n - 1)
puts the return array into the variable arr
.
а что значит -1?я так понимаю что если он возвращает 5 массивов тогда на выходе будет 4 массива?
There is only 1 array, not 5 arrays or 4 arrays.
The function call countdown(n - 1)
returns one array that contains a countdown from n - 1
to 0
.
мне бы на примере это показать,я это понимаю так есть один массив [arr]больше добавить нельзя?
These three lines say
Create an array with a countdown from n - 1
to 0
and store it in the variable arr
Put n
an the front of that array with the unshift
method so now arr
is a countdown from n
to 0
return this updated countdown arr
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.