Jump to content

Comparing Strings


Nate

Recommended Posts

I know Java and Javascript are completely different. In Java you need to use methods to compare strings to return a boolean answer. In javascript do you use some type of other method? or just use "==" in an if statement? I don't know if Strings are objects in this script. I'm new to learning and understanding it. Thank you for your help.Nate :)

Link to post
Share on other sites
I know Java and Javascript are completely different. In Java you need to use methods to compare strings to return a boolean answer. In javascript do you use some type of other method? or just use "==" in an if statement? I don't know if Strings are objects in this script. I'm new to learning and understanding it. Thank you for your help.Nate :)

== I think:)eg.if ("xxx" == "xx") {alert ('xxx')}if ("xxx" == "xxx") {alert ('xx')}spider
Link to post
Share on other sites

Yes you just use ==like:

<head><script type="text/javascript">var test="Hello";if (test=="Hello") alert("hello");else alert("Goodbye");</script></head>

Link to post
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...