To get the perimeter of a rectangle, you can follow these steps:
function calculateRectanglePerimeter(width, height) {
return 2 * width + 2 * height;
}
// specify the width
let w = 5; // adjust as needed
// specify the height
let h = 8; // adjust as needed
// call the function with the specified width and height
console.log(calculateRectanglePerimeter(w, h));
You can also store the calculated perimeter in a variable before displaying it on the console:
function calculateRectanglePerimeter(width, height) {
return 2 * width + 2 * height;
}
// specify the width
let w = 5; // adjust as needed
// specify the height
let h = 8; // adjust as needed
// call the function with the specified width and height
let perimeter = calculateRectanglePerimeter(w, h);
// display the perimeter on the console
console.log(perimeter);