js-mentorship-razvan / javascript

Javascript study notes
GNU General Public License v3.0
22 stars 2 forks source link

Frugal Pizza #499

Closed RazvanBugoi closed 4 years ago

RazvanBugoi commented 4 years ago

https://www.codewars.com/kata/58e4fbd63258cefa4100002c/train/javascript

RazvanBugoi commented 4 years ago
function pizzaPrice(diameter, price) {
  let output = price / (Math.PI * (Math.pow(diameter/2, 2)));
  return typeof diameter == 'number' && typeof price == 'number' ? Number(output.toFixed(2)) : 0;
}