-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathday4-create-a-rectangle-object.js
More file actions
31 lines (26 loc) · 982 Bytes
/
Copy pathday4-create-a-rectangle-object.js
File metadata and controls
31 lines (26 loc) · 982 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/*
Objective
In this challenge, we practice creating objects. Check out the attached tutorial for more details.
Task
Complete the function in the editor. It has two parameters: a and b. It must return an object modeling a rectangle that has the following properties:
- length: This value is equal to a.
- width: This value is equal to b.
- perimeter: This value is equal to 2 * (a + b)
- area: This value is equal to a * b
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 a.
- The second line contains an integer denoting b.
Constraints
1 <= a, b <= 100
Output Format
Return a object that has the properties specified above. Locked code in the editor prints the returned object's lenght, width, perimeter, and area to STDOUT.
*/
function Rectangle(a, b) {
return {
"length": a,
"width": b,
"perimeter": 2 * (a + b),
"area": a * b
}
}