Skip to content

Commit

Permalink
Create RectangleObjHR.js
Browse files Browse the repository at this point in the history
  • Loading branch information
saksham101 authored Jun 12, 2020
1 parent db063ad commit 8487b27
Showing 1 changed file with 71 additions and 0 deletions.
71 changes: 71 additions & 0 deletions RectangleObjHR.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
/*
Task
Complete the function in the editor. It has two parameters: and . It must return an object modeling a rectangle that has the following properties:
: This value is equal to .
: This value is equal to .
: This value is equal to
: This value is equal to
Note: The names of the object's properties must be spelled correctly to pass this challenge.
Input Format
The first line contains an integer denoting .
The second line contains an integer denoting .
Constraints
Output Format
Return a object that has the properties specified above. Locked code in the editor prints the returned object's , , , and to STDOUT.
Sample Input 0
4
5
Sample Output 0
4
5
18
20
Explanation 0
Given a of and a of , the Rectangle object's is and its is .
*/
// SOLUTION
'use strict';

process.stdin.resume();
process.stdin.setEncoding('utf-8');

let inputString = '';
let currentLine = 0;

process.stdin.on('data', inputStdin => {
inputString += inputStdin;
});

process.stdin.on('end', _ => {
inputString = inputString.trim().split('\n').map(string => {
return string.trim();
});

main();
});

function readLine() {
return inputString[currentLine++];
}

/*
* Complete the Rectangle function
*/
function Rectangle(a, b) {
this.length = a;
this.width = b;
this.perimeter = 2*(a+b);
this.area = a*b;
}

0 comments on commit 8487b27

Please sign in to comment.