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

[Codewars] Area of a Square (8 kyu) / JavaScript

by fluss 2023. 4. 12.

https://www.codewars.com/kata/5748838ce2fab90b86001b1a

 

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 calculates the area of the red square, when the length of the circular arc A is given as the input. Return the result rounded to two decimals.

Note: use the π value provided in your language (Math::PI, M_PI, math.pi, etc)

 

코드

function squareArea(A){
  return (A * 2 / Math.PI) ** 2;
}

댓글