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