Strings are immutable. Calling toLowerCase() or toUpperCase() on a string results in a new string. If you want to use that new string, you have to return it or assign it to something, or something like that.
Here, take the first letter and call toUpperCase on it. Then concatenate it with the rest of the letters which have toLowerCase called on them:
function capFirstLetter(str) {
  return str.split(' ')
    .map(word => word[0].toUpperCase() + word.slice(1).toLowerCase())
    .join(' ');
}
console.log(capFirstLetter('foo bAR'));