<!DOCTYPE html>
<html>
<body>

<p>Click the button to compare two strings in the current locale.</p>

<button onclick="myFunction()">Try it</button>

<p id="demo"></p>

<script>
function myFunction() {
    var str1 = "cd";
    var str2 = "ab";
    var n = str1.localeCompare(str2);
    document.getElementById("demo").innerHTML = n;
}
</script>

</body>
</html>