Skip to main content
Stack Overflow
  1. About
  2. For Teams

Return to Revisions

2 of 2
added 492 characters in body
nuala
  • 2.7k
  • 4
  • 33
  • 54

You try to call toLowerCase() on an Array which provides no toLowerCase() method. Instead you should specify an item in that array like:

cname = name[0].toLowerCase().replace(/ /g, ''),

This is easy to spot of you open the console of your browser as running it in Chrome gave me this message:

Uncaught TypeError: Object Abraham Lincoln,George Washington has no method 'toLowerCase'

As comments on your questions indicate you probably don't want to hard code the index of the element but instead use a loop. I tried to fiddle around with your code but it seems some input from #body is missing to get some semantic in your lines so all I can provide is one suggestion how to loop over an array of srings:

var name = ['Abraham Lincoln', 'George Washington'];
$(name).each(function(key, value){
 console.log(value.toLowerCase());
});
​
nuala
  • 2.7k
  • 4
  • 33
  • 54

AltStyle によって変換されたページ (->オリジナル) /