JSFiddle - React, Tailwind, and code Playground

by Brock Callahan

HTML

<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<h1 id="output"></h1>    
<h2 id="output2"></h2>

JavaScript

var whatLength = prompt("What is the length of the room?");
var whatWidth = prompt("What is the width of the room?");

writeIt("output", "You need " + carpet(whatLength, whatWidth) + " rolls.");

function carpet(l, w) {
    var length = Math.round(l * 2) / 2;
    var width = Math.round(w * 2) / 2;
    var sqft = length * width;
    var cutSize = 12 * 12;
    if (l || w < 12) {
    	var hallLength = Math.ceil(l / 12);
        return hallLength;
    }
    var howManyRolls = sqft / cutSize;
    return Math.ceil(howManyRolls);
};

function writeIt(id, text) {
    document.getElementById(id).innerHTML = text;
};