function appendList(objList, elmName) {
    // Clear previous child elements if content is updated
    let listNode = document.getElementById(elmName);
    while(listNode.firstChild) {
        listNode.removeChild(listNode.firstChild);
    }

    objList.forEach(function(obj) {
        let node = document.createElement('li');
        let textNode = document.createTextNode(obj);
        node.append(textNode);
        document.getElementById(elmName).appendChild(node);
    });
}
//I separated the two to show how updating a list does not need to specify value
I separated the two to show how updating a list does not need to specify value
I separated the two to show how updating a list does not need to specify value
function appendList(objList, elmName) {
    let listNode = document.getElementById(elmName);
    while(listNode.firstChild) {
        listNode.removeChild(listNode.firstChild);
    }
    objList.forEach(function(obj) {
        let node = document.createElement('li');
        let textNode = document.createTextNode(obj);
        node.append(textNode);
        document.getElementById(elmName).appendChild(node);
    });
}
function appendList ( objList , elmName ) { let listNode = document . getElementById ( elmName ) ; while ( listNode . firstChild ) { listNode . removeChild ( listNode . firstChild ) ; } objList . forEach ( function ( obj ) { let node = document . createElement ( 'li' ) ; let textNode = document . createTextNode ( obj ) ; node . append ( textNode ) ; document . getElementById ( elmName ) . appendChild ( node ) ; } ) ; }
I separated the two to show how updating a list does not need to specify value
I separated the two to show how updating a list does not need to specify value
// Clear previous child elements if content is updated