Text.ToupperCase no es una función

var hello = "Hello, ";

function greet(names) {

  if (name == null) {
    console.log(hello + "my friend")
  } else if (name == name.toUpperCase()) {
    console.log(hello.toUpperCase() + name.toUpperCase())
  } else {
    console.log(hello + name);
  }
}

var names = ["jack", "john"]
greet(names);
 Run code snippetHide results
Brave Bee