 # Day 1: Arithmetic Operators in Javascript| HackerRank Solutions

Arithmetic operators in javascript!!!

Hello programmers, today we are sharing proper solutions with all test cases passed of 10 Days of JavaScript by HackerRank.

As you all know JavaScript is the most popular and the most challenging programming language to conquer but nowadays it’s not. There are some amazing platforms where they provide challenges on different languages and HackerRank is one of them.

So in this Day1: Arithmetic Operators in JavaScript HackerRank Solution we will discuss how we can solve this problem very easily. Basically, we have to complete two functions i.e. getArea() and getPerimeter().

In the getArea() function we have to return the area of a rectangle and in the getPerimeter() function return the perimeter of a rectangle.

Before checking out the solution it’s highly recommended to do it by yourself first because these challenges will help you to think about how to deal with these real-world problems.

Let’s get started.

Here are a couple of related posts you may find helpful, too:

## Overview: 10 Days of JavaScript

This series focuses on learning and practicing JavaScript. Each challenge comes with a tutorial article, and you can view these articles by clicking either the Topics tab along the top of the article icon in the right-hand menu.

Objective

In this challenge, we practice using arithmetic operators. Check out the attached tutorial for resources.

Complete the following functions in the editor below:

1. `getArea(length, width)`: Calculate and return the area of a rectangle having sides length and width.
2. `getPerimeter(length, width)`: Calculate and return the perimeter of a rectangle having sides length and width.

The values returned by these functions are printed to stdout by locked stub code in the editor.

Input Format

Constraints

1. 1 <= length, width <= 1000
2. length and width are scaled to at most three decimal places.

Output Format

Sample Input 0

```3
4.5
```

Sample Output 0

```13.5
15
```

Explanation 0

The area of the rectangle is length x width = 3 x 4.5 = 13.5.
The perimeter of the rectangle is 2 x (length + width) = 2 x (3 + 4.5) = 15.

## Solution – 10 Days of JavaScript Hackerrank Solutions

```/**
*   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) {
let area;
area= length*width;
return area;
}

/**
*   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) {
let perimeter;