georgiev955

Untitled

Feb 12th, 2023
272
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. function solve(input) {
  2. let shape = input[0];
  3. let area = 0;
  4. if (shape === "square") {
  5. area = Number(input[1])*Number(input[1]);
  6. } else if (shape === "rectangle") {
  7. area = Number(input[1])*Number(input[2]);
  8. } else if (shape === "circle") {
  9. area = Number(input[1])*Number(input[1])*Math.PI;
  10. } else if (shape === "triangle") {
  11. area = Number(input[1])*Number(input[2])/2;
  12. }
  13. console.log(`${area.toFixed(3)}`);
  14. }
Advertisement
Add Comment
Please, Sign In to add comment