{"size": 823, "ext": "js", "max_stars_repo_path": "js/18.removeChild.js", "max_stars_repo_name": "schtiell/DhtmlCourse21", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "js/18.removeChild.js", "max_issues_repo_name": "schtiell/DhtmlCourse21", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "js/18.removeChild.js", "max_forks_repo_name": "schtiell/DhtmlCourse21", "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": 18.7045454545, "max_line_length": 97, "alphanum_fraction": 0.6391251519}
console.log('removeChild');


let contador = 1;


var agregarElemento = function () {

    //console.log("Elemento agregado!!!");

    let salto = "\n";

    let textNode = document.createTextNode(` ${contador}: Nodo de texto creado ${salto}`);

    let parrafo = document.getElementById('parrafo');

    parrafo.appendChild(textNode);

    contador += 1;
}



var eliminarElemento = function () {

    // console.log("Elemento eliminado!!!");

    let parrafo = document.getElementById("parrafo");


    //hasChildNodes() retorna true si el nodo tiene hijos (sean de tipo texto o de tipo elemento)
    if (parrafo.hasChildNodes()){

        //obtiene el ultimo elemento hijo
        parrafo.removeChild(parrafo.lastChild);

        contador -= 1;
    }else{
        console.log("No hay mas hijos para remover");
    }



}