Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function areaOfFigures(input) {
- let type = input[0];
- let result = 0;
- if (type === "square") {
- let a = Number(input[1]);
- result = a * a;
- } else if (type === "rectangle") {
- let a = Number(input[1]);
- let b = Number(input[2]);
- result = a * b;
- } else if (type === "circle") {
- let radius = Number(input[1]);
- result = Math.pow(radius, 2) * Math.PI;
- } else {
- let a = Number(input[1]);
- let height = Number(input[2]);
- result = a * height / 2;
- }
- console.log(result.toFixed(3));
- }
- areaOfFigures(["square", "5"])
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement