LocaleCompare-2

 

JavaScript localeCompare function will return 0 because str1 and str2 are same.

 
 
 
<!DOCTYPE html> <html> <head> <title>Welcome to LearnKode - A code learning platform</title> </head> <body> <button onclick="compareString()">Compare Strings</button> <p id="sample"></p> <script> function compareString() { var str1 = "LearnKode"; var str2 = "LearnKode"; var result = str1.localeCompare(str2); document.getElementById("sample").innerHTML = result; } </script> </body> </html>
Output