JSFiddle - React, Tailwind, and code Playground

by ainop

HTML

<textarea id="text"></textarea><br/>
<button onclick="calc()">Calc!</button>

JavaScript

function calc() {
    var reEstimate = /=== (\d*(\.\d+)?)h/g;

    var text = document.querySelector('#text').value;

    var estimate, totalEstimate = 0;
    while (estimate = reEstimate.exec(text)) {
        console.log(estimate);
        totalEstimate += parseInt(estimate[1], 10);
    }

    alert(totalEstimate);
}