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 comment
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 comment
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 comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...