Hi I want to use JS to apply a class to the last list element in a list with a class list-items. I cobbled together something but I can't get it to work

function removeUnderline () {
	  // get all ul elements
          var List = document.getElementsByTagName("ul");	
         // if element has a class list-links
         if (List.className == "list-links") {		
                 // loop through list items
                 for (i=0; i<List.childNodes.length; i++) {
                           // for the last list item give it a class of no-underline
                           if (List.lastChild) {					  
                                   List.lastChild.className= "no-underline";			 
any ideas?