본문 바로가기
알고리즘/Codewars

[Codewars] Reversed sequence (8 kyu) / JavaScript

by fluss 2023. 1. 20.

https://www.codewars.com/kata/5a00e05cc374cb34d100000d

 

Codewars - Achieve mastery through coding practice and developer mentorship

A coding practice website for all programming levels – Join a community of over 3 million developers and improve your coding skills in over 55 programming languages!

www.codewars.com

 

DESCRIPTION:

Build a function that returns an array of integers from n to 1 where n>0.

Example : n=5 --> [5,4,3,2,1]

 

코드

const reverseSeq = n => {
  let arr = [];
  for(let i = n; i > 0; i--){
    arr.push(i);
  }
  return arr;
};

댓글