Answers for "javascript how to sort variables by user input"

0

javascript how to sort variables by user input

<!DOCTYPE html>
<html>
<body>

    <p>Type x, y, zand click "Sort" to get them sorted</p>
    <button onclick="sort()">sort</button>

    <p id="answer"></p>

<script>

    var x = window.prompt("x=?");    
    var y = window.prompt("y=?");
    var z = window.prompt("z=?");

    var zmienne = [x,y,z];
    document.getElementById("answer").innerHTML = zmienne;

    function sortuj() {
        zmienne.sort();
        document.getElementById("answer").innerHTML = zmienne;
    }

</script>

</body>
</html>
Posted by: Guest on December-29-2020

Code answers related to "javascript how to sort variables by user input"

Code answers related to "Javascript"

Browse Popular Code Answers by Language