forked from nathan-abela/HackerRank-Solutions
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path03 - Day 1 - Arithmetic Operators.js
More file actions
39 lines (31 loc) · 1002 Bytes
/
03 - Day 1 - Arithmetic Operators.js
File metadata and controls
39 lines (31 loc) · 1002 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
32
33
34
35
36
37
38
39
// ========================
// Information
// ========================
// Direct Link: https://www.hackerrank.com/challenges/js10-arithmetic-operators/problem
// Difficulty: Easy
// Max Score: 10
// Language: JavaScript (Node.js)
// ========================
// Solution
// ========================
// 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 getArea(length, width) {
return length*width;
}
// 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 getPerimeter(length, width) {
// Write your code here
return 2*(length+width);
}
function main() {
const length = +(readLine());
const width = +(readLine());
console.log(getArea(length, width));
console.log(getPerimeter(length, width));
}