JSFiddle - React, Tailwind, and code Playground

by Ranjan Kumar

HTML

<pre>
Number of time GetLength() called : <input id="fcall" name="fcall" value="0" />

<input type="button" onclick="javascript:ExecuteLoopOne()" value="ExecuteLoopOne" />
    
<input type="button" onclick="javascript:ExecuteLoopTwo()" value="ExecuteLoopTwo" />
</pre>

JavaScript

function GetLength()
{
    var currValue = parseInt($F("fcall"));
    $("fcall").value = currValue + 1;
    return 10;
}

function ExecuteLoopOne()
{
    $("fcall").value = 0;
    for(var i=0; i <= GetLength(); i++)
    {
        console.log(i);
    }
}

function ExecuteLoopTwo()
{
    $("fcall").value = 0;
    for(var i=0, len = GetLength(); i <= len; i++)
    {
        console.log(i);
    }
}