Please note, this is a STATIC archive of website www.tutorialspoint.com from 11 May 2019, cach3.com does not collect or store any user information, there is no "phishing" involved.
Tutorialspoint

Comparing String using Javascript

<html>
   <body>
   
      <script type = "text/javascript">
         <!--
            var book = "maths";
            if( book == "history" ) {
               document.write("<b>History Book</b>");
            }
         
            else if( book == "maths" ) {
               document.write("<b>Maths Book</b>");
            }
         
            else if( book == "economics" ) {
               document.write("<b>Economics Book</b>");
            }
         
            else {
               document.write("<b>Unknown Book</b>");
            }
         //-->
      </script>
      
      <p>Set the variable maths to different value and then try...</p>
   </body>
<html>

Advertisements
Loading...

We use cookies to provide and improve our services. By using our site, you consent to our Cookies Policy.