Wednesday, May 6, 2015

Javascript's indexOF is case oriented

Our own little javascript's little cute indexOf function is case sensitive and I am surprised why???

so var s = 'hello world';

s.indexOf('hello') returns 1 and s.indexOf('HELLO') returns -1

Aaaarrrrrrrggggggghhhhh...... Lets enjoy this :)





Solution I forgot (Bad habit to rush to you tube for new songs hehe he he.....)

 s..toLowerCase().indexOf('HELLO') is good to go   ;)


No comments:

Post a Comment