{"size": 686, "ext": "js", "max_stars_repo_path": "Loops/Loops/scripts/numbersFrom1ToN.js", "max_stars_repo_name": "DennyGD/JavaSciptBasics", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "Loops/Loops/scripts/numbersFrom1ToN.js", "max_issues_repo_name": "DennyGD/JavaSciptBasics", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "Loops/Loops/scripts/numbersFrom1ToN.js", "max_forks_repo_name": "DennyGD/JavaSciptBasics", "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": 19.6, "max_line_length": 81, "alphanum_fraction": 0.5583090379}
﻿function numbersToN() {
    var num = document.getElementById("input-first-task").value,
        result;

    if (validateNumber(num)) {
        result = getOutput(parseInt(num));
    } else {
        result = "Invalid input.";
    }

    console.log("Numbers from 1 to N:");
    console.log(result);
    document.getElementById("first-task-result").innerText = "Result: " + result;
}


function validateNumber(input) {
    if (isFinite(input) === false || input < 2) {
        return false;
    } else {
        return true;
    }
}

function getOutput(number) {
    var output = "1";

    for (var i = 2; i <= number; i++) {
        output +=  ", " + i;
    }

    return output;
}

