Advertisement
tr00per92

09-treehouse

Jul 15th, 2014
654
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function treeHouseCompare() {
  2.     var a = arguments[0];
  3.     var b = arguments[1];
  4.     var houseArea = a * a + (a * (a * 2 / 3)) / 2;
  5.     var treeArea = b * (b / 3) + Math.PI * (b * 2 / 3) * (b * 2 / 3);
  6.     if (houseArea > treeArea) {
  7.         return "house/" + houseArea.toFixed(2);
  8.     } else {
  9.         return "tree/" + treeArea.toFixed(2);
  10.     }
  11. }
  12. console.log(treeHouseCompare(3, 2));
  13. console.log(treeHouseCompare(3, 3));
  14. console.log(treeHouseCompare(4, 5));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement