function appendList(objList, elmName) {
    // Clear previous child elements first
    let list1Node = document.getElementById(elmName);
    while(list1Node.firstChild) {
        list1Node.removeChild(list1Node.firstChild);
    }

    objList.forEach(function(obj) {
        let node = document.createElement('li');
        let textNode = document.createTextNode(obj);
        node.append(textNode);
        document.getElementById(elmName).appendChild(node);          
    });
}
/** 
 * The following appendList function is used on both cases
*/
The following appendList function is used on both cases
The following appendList function is used on both cases
function appendList(objList, elmName) {
    let list1Node = document.getElementById(elmName);
    while(list1Node.firstChild) {
        list1Node.removeChild(list1Node.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 list1Node = document . getElementById ( elmName ) ; while ( list1Node . firstChild ) { list1Node . removeChild ( list1Node . firstChild ) ; } objList . forEach ( function ( obj ) { let node = document . createElement ( 'li' ) ; let textNode = document . createTextNode ( obj ) ; node . append ( textNode ) ; document . getElementById ( elmName ) . appendChild ( node ) ; } ) ; }
The following appendList function is used on both cases
The following appendList function is used on both cases
// Clear previous child elements first