Advertisement
Guest User

Untitled

a guest
Nov 20th, 2019
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. function area(input) {
  2. let figureType = input.shift(2);
  3. let area = 0.0;
  4. switch (figureType) {
  5. case "square": {
  6. let a = input.shift(2);
  7. area = a * a;
  8. break;
  9. }
  10. case "rectangle": {
  11. let a = input.shift(2);
  12. let b = input.shift(2);
  13. area = a * b;
  14. break;
  15. }
  16. case "circle": {
  17. let a = input.shift(2);
  18. area = Math.PI * a * a;
  19. break;
  20. }
  21. case "triangle": {
  22. let a = input.shift(2);
  23. let b = input.shift(2);
  24. area = 2 * b +a;
  25. break;
  26.  
  27. }
  28. }console.log(area.toFixed(3));
  29. }
  30. area(['circle',6]);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement