PROBLEM 16
Easy

Rectangle Perimeter

Programming Basics · JavaScript

</>
STATUS Not solved

TASK

Problem

#16

Given rectangle sides `a` and `b`, print its perimeter.

EXAMPLE

Example

Input
4 7
Output
22

LIMITS

Constraints

a > 0; b > 0
📖
LEARN Theory for this problem
+

### Rectangle Perimeter

JavaScript arithmetic works with numeric values stored in variables. A clear solution reads the needed values, computes the formula with `+`, `-`, `*`, `/` or `**`, and prints only the final result.

💡
NEED HELP? Hints
+

['Write the formula using named intermediate values if it contains more than one operation.', 'Match each input value type to the operation performed on it: JavaScript string and numeric behavior differ significantly.']

ANSWER Solution
+
const fs = require('fs');
const input = fs.readFileSync(0, 'utf8').trimEnd();
let [a, b] = input.trim().split(/\s+/).filter(Boolean).map(Number);
let result = ((2) * (a + b));
console.log(result);