Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <title>Study</title>
- </head>
- <body>
- <script>
- 'use strict'
- function rectPrint(rectObj) {
- console.log(`Rectangle info:`);
- console.log(`leftUp(${rectObj.leftUpX}, ${rectObj.leftUpY})`);
- console.log(`rightDown(${rectObj.rightDownX}, ${rectObj.rightDownY})`);
- }
- function rectWidth(rectObj) {
- return rectObj.rightDownX - rectObj.leftUpX;
- };
- function rectHihgt(rectObj) {
- return rectObj.rightDownY - rectObj.leftUpY;
- };
- function rectPerimeter(rectObj) {
- return rectWidth(rectObj) * 2 + rectHihgt(rectObj) * 2;
- };
- function rectChangeWidth(rectObj, width) {
- rectObj.rightDownX = rectObj.leftUpX + width;
- };
- //let rect = { leftUp: { x: 0, y: 0 }, rightDown: { x: 10, y: 10 } };
- {
- let rect = { leftUpX: 0, leftUpY: 0, rightDownX: 10, rightDownY: 10 };
- let rect1 = { leftUpX: 20, leftUpY: 20, rightDownX: 45, rightDownY: 45 };
- rectPrint(rect);
- rectPrint(rect1);
- console.log(`rect width is: ${rectWidth(rect)}`);
- console.log(`rect1 hight is: ${rectHihgt(rect1)}`);
- console.log(`rect perimetr is: ${rectPerimeter(rect)}`);
- console.log(`rect1 perimetr is: ${rectPerimeter(rect1)}`);
- rectChangeWidth(rect, 20);
- rectPrint(rect);
- console.log(`rect width is: ${rectWidth(rect)}`);
- console.log(`rect perimetr is: ${rectPerimeter(rect)}`);
- }
- </script>
- </body>
- </html>
Add Comment
Please, Sign In to add comment