JS Assi4
JS Assi4
JavaScript Code
function set_string()
{
var string1 = document.getElementById("st1").value;
var string2 = document.getElementById("st2").value;
com1(string1,string2);
com2(string1,string2);
com3(string1,string2);
com4(string1,string2);
function com1(string1,string2)
{
var ot;
const result1 = string1.toUpperCase() ===
string2.toUpperCase();
if(result1) {
ot="The strings are similar ";
} else {
ot="The strings are not similar ";
document.getElementById("casing").innerHTML=ot;
function com2(string1,string2)
{
if(result2) {
ot="The strings are similar <br><br>";
} else {
ot="The strings are not similar <br><br>";
}
document.getElementById("regex").innerHTML=ot;
}
function com3(string1,string2)
{
if(result3 == 0) {
ot="The strings are similar <br><br>";
} else {
ot="The strings are not similar <br><br>";
document.getElementById("locom").innerHTML=ot;
}
function com4(string1,string2)
{
var ot;
}
else
{
ot="The strings are not similar";
document.getElementById("equality").innerHTML=ot;
}
HTML Code
<!DOCTYPE html>
<html>
<body style="text-align:center">
<h1>String Comparison</h1>
<h1>42231 Pratyush Ingale</h5>
<br>
String 1= <input type="text" id="st1" value=" ">
<br></br>
String 2= <input type="text" id="st2" value=" ">
<br><br>
<button style="background:rgb(255, 255, 255)" id="myBtn"
onclick="set_string()">Compare Strings</button>
<br><br>Result using to uppercase() method= <p id="casing"></p>
<br><br> Result using to RegEx method: <p id="regex"></p>
<br><br> Result using localeCompare method: <p id="locom"></p>
<br><br> Result using Strict Eqaulity method: <p id="equality"></p>
<script src="assignment_4.js"></script>
</body>
</html>