let start = alert( "This is a shape detector program.\nYou will be asked to enter four sides and four angles to determine the quadrilateral." ); let obj = {}; for (let s = 1; s <= 4; s++) { obj[`side${s}`] = Number(prompt(`Define length ${s}: `)); } const { side1, side2, side3, side4 } = obj; let obj2 = {}; for (let a = 1; a <= 4; a++) { obj2[`corner${a}`] = Number(prompt(`Define angle ${a}: `)); } const { corner1, corner2, corner3, corner4 } = obj2; //if...else if...else statement if (side1 === side3 && side2 === side4 && side1 === side4 && corner2 === 90 && corner4 === 90 && corner1 === 90 && corner3 === 90) { console.log("This is a square."); //Square: all sides equal, all corners 90 degrees } else if (side1 === side3 && side2 === side4 && corner2 === 90 && corner4 === 90 && corner1 === 90 && corner3 === 90) { console.log("This is a Rectangle."); //Rectangle: opposite sides equal, all corners 90 degrees. } else if (side1 === side3 && side2 === side4 && side1 === side4 && corner1 < 90 && corner3 < 90 && corner2 > 90 && corner4 > 90) { console.log("This is a Rhombus."); //Rhombus: all sides equal, opposite angles equal. Two opposite corners are less than 90 degrees,the other two corners are more than 90 degrees. } else if (side1 === side3 && side2 === side4 && corner2 > 90 && corner4 > 90 && corner1 < 90 && corner3 < 90) { console.log("This is a Parallelogram."); //Parallelogram: Opposite sides equal, opposite angles equal. Two opposite corners are less than 90 degrees, the other two corners are more than 90 degrees. } else { console.log("The determined shape is neither a square, rhombus, rectangle or parallelogram."); }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)