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

[Codewars] What is between? (8 kyu) / JavaScript

by fluss 2023. 4. 14.

https://www.codewars.com/kata/55ecd718f46fba02e5000029

 

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:

Complete the function that takes two integers (a, b, where a < b) and return an array of all integers between the input parameters, including them.

For example:

a = 1
b = 4
--> [1, 2, 3, 4]
 

코드

function between(a, b) {
  const result = [];
  for(let i = a; i <= b; i++){
    result.push(i);
  }
  return result;
}

댓글