{"size": 1206, "ext": "js", "max_stars_repo_path": "script.js", "max_stars_repo_name": "h3XandCoffee/vftvk-Simple-Interest-Calculator", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "script.js", "max_issues_repo_name": "h3XandCoffee/vftvk-Simple-Interest-Calculator", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "script.js", "max_forks_repo_name": "h3XandCoffee/vftvk-Simple-Interest-Calculator", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 40.2, "max_line_length": 106, "alphanum_fraction": 0.6111111111}
function compute()
{
    var principal = document.getElementById("principal").value;
    var rate = document.getElementById("rate").value;
    var years = document.getElementById("years").value;
    var interest = principal * years * rate /100;
    var year = new Date().getFullYear()+parseInt(years);
    var result = document.getElementById("result");
    if (principal <= 0) {
        alert ("Enter a positive number");

        /* TODO: Consider getting the element only once and use it's value property and focus() method */
        document.getElementById("principal").focus();

    /* TODO: Consider using return insted of else branch */
    } else {
        result.innerHTML = "If you deposit <mark>" + principal + "</mark><br>"
                        + "at an interest rate of <mark>" + rate + "</mark>.<br>"
                        + "You will receive an amount of <mark>" + interest + "</mark>,<br>"
                        + "in the year " + (Number(new Date().getFullYear()) + Number(years)) + "</mark>";
    }
}

/* Rate slider updater function */
function updateRate() 
{
    var rateval = document.getElementById("rate").value;
    document.getElementById("rate_val").innerText=rateval;
}
