@pedau strings and numbers are objects. The objects have a series of built in methods (ways of manipulating the object). For instance a string of:
var name = “pedau”;
has a method toUpperCase() which converts the string to uppercase like this:
which results in:
name = "PEDAU";
When you try to call method on an object that doesn’t exist as in this example
console.log( names.toUpperCase() );
You will get the error you’ve been getting because names doesn’t exist (we defined name in the function) and since names doesn’t exist the method toUpperCase() will not exist.
In your case you may be dealing with a typo (names vs name), you may be trying to pass a variable that has never been defined OR you may have something like this:
and since name has been declared but not defined it will also have no methods attached to it.
If I were debugging this, I’d first do a quick scan of the variables/names being passed in and make sure all those are being set. Next I’d console.log() the variables and see which one is not being set. This should pop up fairly quickly.