JavaScript Practice Questions And Answer

Problem: Write a program to take two strings as input from the user. Confirm that the strings are equal.
Solution:
            <html>
              <head>
                <script>
                  function demo1()
                  {
                    var str1 = document.getElementById("input1").value
                    var str2 = document.getElementById("input2").value
                    if(str1 == str2)
                   {
                    document.write("both strings same")
                   }
                    else
                    {
                      document.write("Not same")
                    }  
                  }
             </script>
            </head>
            <body>
                <input type= "text" id="input1" placeholder="enter data"/>
                <br>
                <input type= "text" id="input2" placeholder="enter data"/>
                <br><br>
                <input type="button" value="Check Equal" onclick="demo1()" /><br>
            </body>
        </html>
          

Contact Us

Our Address

Office no.- 401,Shekhar Central Building ,Palasiya, Pin-code:452001, Indore

Email Us

contact@codebetter.in

Call Us

+91 88230 75444, +91 99939 28766

Loading
Your message has been sent. Thank you!