Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8
  1. #1
    New Coder
    Join Date
    Jul 2011
    Posts
    18
    Thanks
    2
    Thanked 0 Times in 0 Posts

    string comparison operation

    are these right ya?

    '3' !=='smith' true
    "test" == "test " true
    '2' != 'smith' true
    "exam" == "Exam" true
    5 === "5 " false
    "t" > "T" false
    "y" >= "p" true
    "Happy" == "happy " true

  • #2
    Banned
    Join Date
    Feb 2011
    Posts
    2,699
    Thanks
    13
    Thanked 395 Times in 395 Posts
    run the code and see what happens

    That will tell you if they are right or not.

  • #3
    New Coder
    Join Date
    Jul 2011
    Posts
    18
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by bullant View Post
    run the code and see what happens

    That will tell you if they are right or not.
    dont have linux!

  • #4
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    17,928
    Thanks
    203
    Thanked 2,531 Times in 2,509 Posts
    Quote Originally Posted by university View Post
    dont have linux!
    What has Linux (an operating system) to do with it?

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.

  • #5
    Regular Coder Krupski's Avatar
    Join Date
    Dec 2010
    Location
    United States of America
    Posts
    505
    Thanks
    39
    Thanked 47 Times in 46 Posts
    Quote Originally Posted by university View Post
    dont have linux!
    You don't need Linux.

    Make yourself a mini webpage and run your statements as Javascript.

    Code:
    <html>
    <head>
    <script type="text/javascript">
    
    alert('3' !=='smith');
    
    </script>
    </head>
    <body>
    </body>
    </html>
    Take that code and save it as "test.html" then use your web browser to load it. Go to "file" / "open file", find test.html and open it. A popup will appear and say "true" or "false".

    You can edit "test.html" as much as you want and verify anything you like.

    (by the way, you have posted several different threads asking for help with what is surely HOMEWORK. We can give you guidance but not do it all for you. TRY FIRST, post what you tried THEN we can help you. Nobody is going to write it all for you).
    "Anything that is complex is not useful and anything that is useful is simple. This has been my whole life's motto." -- Mikhail T. Kalashnikov

  • #6
    New Coder
    Join Date
    Jul 2011
    Posts
    18
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Philip M View Post
    What has Linux (an operating system) to do with it?
    lol sorry dont know why i wrote that haha!.

  • #7
    New Coder
    Join Date
    Jul 2011
    Posts
    18
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Krupski View Post
    You don't need Linux.

    Make yourself a mini webpage and run your statements as Javascript.

    Code:
    <html>
    <head>
    <script type="text/javascript">
    
    alert('3' !=='smith');
    
    </script>
    </head>
    <body>
    </body>
    </html>
    Take that code and save it as "test.html" then use your web browser to load it. Go to "file" / "open file", find test.html and open it. A popup will appear and say "true" or "false".

    You can edit "test.html" as much as you want and verify anything you like.

    (by the way, you have posted several different threads asking for help with what is surely HOMEWORK. We can give you guidance but not do it all for you. TRY FIRST, post what you tried THEN we can help you. Nobody is going to write it all for you).
    okay so can i use notepad as i dont have editplus..beacause i tried it but nothing comes up because theres nothing written in the body tag?

  • #8
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    25,211
    Thanks
    75
    Thanked 4,343 Times in 4,309 Posts
    But the alert() should still come up.

    Works fine for me. Alerts "true" as expected.

    If you prefer to see the stuff in the <body>, do this:
    Code:
    <html>
    <body>
    '3' !== 'smith' ?
    <script type="text/javascript">
    document.write('3' !=='smith');
    </script>
    <hr>
    "Happy" == "happy" ?
    <script type="text/javascript">
    document.write("Happy" == "happy");
    </script>
    </body>
    </html>
    Clumsy coding, but it will do the job.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •