-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
03-Arithmetic Operators.js
52 lines (46 loc) · 1.09 KB
/
03-Arithmetic Operators.js
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/*
*-------------------------
* Problem Info
*-------------------------
* Direct Link: https://www.hackerrank.com/challenges/js10-arithmetic-operators/problem
* Difficulty: Easy
* Max Score: 10
* Language: JavaScript (Node.js)
* ------------------------
* Solution
* ------------------------
*/
function getArea(length, width) {
let area;
// Write your code here
area = length * width;
return area;
}
/**
* Calculate the area of a rectangle.
*
* length: The length of the rectangle.
* width: The width of the rectangle.
*
* Return a number denoting the rectangle's area.
**/
function getPerimeter(length, width) {
let perimeter;
// Write your code here
perimeter = 2 * (length + width);
return perimeter;
}
/**
* Calculate the perimeter of a rectangle.
*
* length: The length of the rectangle.
* width: The width of the rectangle.
*
* Return a number denoting the perimeter of a rectangle.
**/
function main() {
const length = +readLine();
const width = +readLine();
console.log(getArea(length, width));
console.log(getPerimeter(length, width));
}