Advertisement
marinvch

Figures

Feb 21st, 2018
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function solve([type, side1, side2]){
  2.     let a = Number(side1);
  3.     let b = Number(side2);
  4.    
  5.     if(type == "square"){
  6.         console.log((a * a).toFixed(3));
  7.     }else if(type == "rectangle"){
  8.         console.log((a * b).toFixed(3));
  9.     }else if(type == "circle"){
  10.         console.log((a * a * Math.PI).toFixed(3));
  11.     }else if(type == "triangle"){
  12.         console.log(((a * b) / 2 ).toFixed(3));
  13.     }
  14. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement