• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

string functions in javascript

 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

How to use string functions in javascript

i write like this

var s1="RAM";
var s2="ram";

if(s1.equalsIgnoreCase(s2))
{
alert("success");
}

its not working

i want use startsWith(),endsWith(),substring() functions also

How to use

Help me,

Thanks in advance
 
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You may use either of toLowerCase() or toUpperCase() method on the String object and apply = operator to check the result. For e.g. the following code

displays "success" on alert message.

- Susanta
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by johny mill:
its not working



This is a singularly useless phrase when reporting a problem. How is it "not working"?

I assume you mean that the alert is not being displayed, but it could also mean that you are getting a JavaScript error or other result. Please be specific.
 
Susanta Chatterjee
Ranch Hand
Posts: 102
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Or if you want to extend functionality of the JavaScript String object by adding a method, you can do the following:



In this case "success" should be displayed.
[ September 20, 2006: Message edited by: Susanta Chatterjee ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic