javascript how to sort variables by user input

Solutions on MaxInterview for javascript how to sort variables by user input by the best coders in the world

showing results for - "javascript how to sort variables by user input"
Mateo
27 Nov 2018
1<!DOCTYPE html>
2<html>
3<body>
4
5    <p>Type x, y, zand click "Sort" to get them sorted</p>
6    <button onclick="sort()">sort</button>
7
8    <p id="answer"></p>
9
10<script>
11
12    var x = window.prompt("x=?");    
13    var y = window.prompt("y=?");
14    var z = window.prompt("z=?");
15
16    var zmienne = [x,y,z];
17    document.getElementById("answer").innerHTML = zmienne;
18
19    function sortuj() {
20        zmienne.sort();
21        document.getElementById("answer").innerHTML = zmienne;
22    }
23
24</script>
25
26</body>
27</html>