popovIliya

March-2022-Conditional Statements - Lab -Area of Figures

Mar 5th, 2022 (edited)
293
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function caculation(input){
  2.     let shape = input[0];
  3.     let area = 0;
  4.     let a = Number(input[1]);
  5.     let b = Number(input[2]);
  6.     if(shape == "square"){
  7.       area = a * a;
  8.     }
  9.     else if( shape == "rectangle"){
  10.         area = a * b;
  11.     }
  12.     else if( shape == "circle"){    
  13.       area = Math.pow(a, 2) * Math.PI;
  14.     }
  15.     else{
  16.         area = (a * b) / 2;
  17.     }
  18.     console.log(area.toFixed(3));
  19. }
Add Comment
Please, Sign In to add comment