https://www.codewars.com/kata/5ab6538b379d20ad880000ab
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:
You are given the length and width of a 4-sided polygon. The polygon can either be a rectangle or a square.
If it is a square, return its area. If it is a rectangle, return its perimeter.
Example(Input1, Input2 --> Output):
6, 10 --> 32
3, 3 --> 9
Note: for the purposes of this kata you will assume that it is a square if its length and width are equal, otherwise it is a rectangle.
코드
const areaOrPerimeter = function(l , w) {
return l === w ? l * w : (l + w) * 2;
};
'알고리즘 > Codewars' 카테고리의 다른 글
[Codewars] Grasshopper - Grade book (8 kyu) / JavaScript (0) | 2023.02.13 |
---|---|
[Codewars] Rot13 (5 kyu) / JavaScript (0) | 2023.02.12 |
[Codewars] Transportation on vacation (8 kyu) / JavaScript (0) | 2023.02.10 |
[Codewars] Write Number in Expanded Form (6 kyu) / JavaScript (0) | 2023.02.09 |
[Codewars] Testing 1-2-3 (7 kyu) / JavaScript (0) | 2023.02.08 |
댓글