TheoH32 / jtf-blog

https://theoh32.github.io/jtf-blog/
MIT License
0 stars 0 forks source link

fib bars woking #5

Open F1nnC opened 7 months ago

F1nnC commented 7 months ago

1st try

Highlighted Code

function setHeight(div) {
    pixels = parseInt(div.id) * 10;
    div.style.height = '${pixels}px';
}

2nd try

Highlighted Code

function measureExecutionTime(func) {
        var startTime = performance.now();
        func();
        var endTime = performance.now();
        return endTime - startTime;
    }

3rd and final

Highlighted Code

function displayTime(functionName, time) {
        var timeDiv = document.getElementById('times');
        var timeDisplay = document.createElement('div');
        timeDisplay.innerHTML = `${functionName}: ${time.toFixed(2)}ms`; // Display time in milliseconds with 2 decimal places
        timeDiv.appendChild(timeDisplay);
    }