<\/span><\/h2>\n\n\n\nComplete the function in the editor. It has two parameters: a<\/em><\/strong> and b<\/em><\/strong>. It must return an object modeling a rectangle that has the following properties:<\/p>\n\n\n\n- length<\/em>:<\/strong> This value is equal to a<\/em><\/strong>.<\/li>
- width<\/strong><\/em>:<\/strong> This value is equal to b<\/strong><\/em>.<\/li>
- perimeter<\/em>:<\/strong> This value is equal to 2 * (a + b)<\/strong>.<\/li>
- area<\/em>:<\/strong> This value is equal to a * b<\/em><\/strong><\/li><\/ul>\n\n\n\n
Note:<\/strong> The names of the object’s properties must<\/em> be spelled correctly to pass this challenge.<\/p>\n\n\n\n<\/span>Input Format<\/strong><\/span><\/h2>\n\n\n\nThe first line contains an integer denoting a<\/em><\/strong>.
The second line contains an integer denoting b<\/em><\/strong>.<\/p>\n\n\n\n<\/span>Constraints<\/strong><\/span><\/h2>\n\n\n\n- 1 <= a<\/em>, b<\/em><= 100<\/strong><\/li><\/ul>\n\n\n\n
<\/span>Output Format<\/strong><\/span><\/h2>\n\n\n\nReturn a object that has the properties specified above. Locked code in the editor prints the returned object’s length<\/em><\/strong>, width<\/em><\/strong>, perimeter<\/em><\/strong>, and area<\/strong><\/em> to STDOUT.<\/p>\n\n\n\nSample Input 0<\/strong><\/p>\n\n\n\n4\n5<\/code><\/pre>\n\n\n\nSample Output 0<\/strong><\/p>\n\n\n\n4\n5\n18\n20<\/code><\/pre>\n\n\n\nExplanation 0<\/strong><\/p>\n\n\n\nGiven a length<\/em><\/strong> of a<\/em> = 4<\/strong> and a width<\/em><\/strong> of b <\/em>= 5<\/strong>, the Rectangle<\/em> object’s perimeter<\/strong><\/em> is 4 + 4 +5 + 5 = 18<\/strong> and its area<\/em><\/strong> is 4*5 = 20<\/strong>.<\/p>\n\n\n\n<\/span>Solution – Day 4: Create a Rectangle Object<\/strong><\/span><\/h2>\n\n\n\n'use strict';\n\nprocess.stdin.resume();\nprocess.stdin.setEncoding('utf-8');\n\nlet inputString = '';\nlet currentLine = 0;\n\nprocess.stdin.on('data', inputStdin => {\n inputString += inputStdin;\n});\n\nprocess.stdin.on('end', _ => {\n inputString = inputString.trim().split('\\n').map(string => {\n return string.trim();\n });\n \n main(); \n});\n\nfunction readLine() {\n return inputString[currentLine++];\n}\n\n\/*\n * Complete the Rectangle function\n *\/\nfunction Rectangle(a, b) {\n this.length = a;\n this.width = b;\n this.perimeter = 2 * (a + b);\n this.area = a * b;\n}\n\n\nfunction main() {\n const a = +(readLine());\n const b = +(readLine());\n \n const rec = new Rectangle(a, b);\n \n console.log(rec.length);\n console.log(rec.width);\n console.log(rec.perimeter);\n console.log(rec.area);\n}<\/pre>\n\n\n\n