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

[Codewars] Quarter of the year (8 kyu) / JavaScript

by fluss 2023. 2. 6.

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

 

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:

Given a month as an integer from 1 to 12, return to which quarter of the year it belongs as an integer number.

For example: month 2 (February), is part of the first quarter; month 6 (June), is part of the second quarter; and month 11 (November), is part of the fourth quarter.

Constraint:

  • 1 <= month <= 12

 

코드

const quarterOf = (month) => {
  return Math.ceil(month / 3);
}

댓글