Build a function that returns an array of integers from n to 1 where n>0
.
Example : n=5
–> [5,4,3,2,1]
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
const reverseSeq = n => {
return Array(n).fill(0).map((e, i) => n - i );
};
Video solution
https://www.youtube.com/watch?v=y1jgbZ8lt1s
const reverseSeq = n => {
let arr = [];
for (let i = n; i > 0; i–) {
arr.push(i);
}
return arr;
};