title: String Comparison shows error on String retrieved from flash[:alert]
body: <p>I am having a javascript code to compare two strings and execute code accordingly.</p>
  
  <p>One String retrieved though rails <strong><em>flash[:alert]</em></strong> and other <strong><em>specified locally</em></strong>.</p>
  
  <pre><code>     &lt;% if flash[:message].present? %&gt;
           var message=new String("&lt;%= flash[:message] %&gt;");
           var message_status=message.localeCompare("mail_sent");
           if(message_status==0)
           {
             // if code....
           }
           else
           {
             alert(message);
             // else code....
           }
      &lt;% end %&gt;
  </code></pre>
  
  <p>Here, ultimately, i am trying to <strong><em>compare two Strings</em></strong>. One retrieved through <code>flash[:alert]</code> and other specified locally i.e <code>mail_sent</code>.</p>
  
  <p>What I observe is </p>
  
  <p><code>It always goes through the else part even though the message displayed in the else part alert is mail_sent.</code> </p>
  
  <p><em>Please Note that when i replaced the <strong>&lt;%= flash[:message] %> with String locally</strong>. It executed the <strong>if part</em></strong>. 
  i.e </p>
  
  <p><code>var message=new String("mail_sent");</code> </p>
  
  <p><strong><em>instead of</em></strong> </p>
  
  <p><code>var message=new String("&lt;%= flash[:message] %&gt;");</code></p>
  
  <p><strong><em>Could anyone say why is it so ?</em></strong> </p>
  
  <p><strong><em>What is need to be done in order to compare two strings in this way?</em></strong> </p>