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

[Codewars] Beginner Series #4 Cockroach (8 kyu) / JavaScript

by fluss 2023. 3. 15.

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

 

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:

The cockroach is one of the fastest insects. Write a function which takes its speed in km per hour and returns it in cm per second, rounded down to the integer (= floored).

For example:

1.08 --> 30

Note! The input is a Real number (actual type is language dependent) and is >= 0. The result should be an Integer.

 

코드

function cockroachSpeed(s) {
  return parseInt(s * 100000 / 3600);
}

댓글