Q:

.replace on array element not working in a loop javascript

I wanted to write a function that gets all the dom elements with the class active and remove that class. I am trying to use the replace method by looping through the array obtained from getElementsByClassName('active') and using replace to replace it with a blank space. Two questions: why isn't the replace method removing the active class and what would be a better alternative to remove class with vanilla js. 
function removeItem(){
  var activeItems = document.getElementsByClassName('active');
  for (i=0; i<activeItems.length; i++){
    var activeClass = activeItems[i].className;
    activeClass.replace('active', '')
  }
}

A:

.replace() returns a string, which you must store, it doesn't overwrite the variable.
activeClass = activeClass.replace('active','');  // this will still need to be set as the classname

Something like this:
function removeClass(){
  var activeItems = document.getElementsByClassName('active');

  for (var i=0,n=activeItems.length; i<n; i++){
     var classes = activeItems[i].className.split(' ') || [];
     for (var j=0,l=classes.length; j<l; j++){
        if(classes[j] === 'active') {
           classes.splice(j,1);
           j--;l--; // we popped a value off the stack
        }
     }
     activeItems[i].className = classes.join(' ');
  }
}

or as zzzzBov suggests, go native:
activeItems[i].classList.remove('active');

