Sort N integer using Array object.
CODING:
<!DOCTYPE html>
<html>
<body>
<h1>Number before Sorting:</h1>
<button onclick="myFunction()">PRESS</button>
<h2 id="here"></h2>
<script>
var points = [40, 100, 1, 5, 25, 10];
function myFunction() {
points.sort(function(a, b){return a-b});
document.getElementById("here").innerHTML ="Number after Sorting:<br>" +points;
}
</script>
</body>
</html>
CODING:
<!DOCTYPE html>
<html>
<body>
<h1>Number before Sorting:</h1>
<button onclick="myFunction()">PRESS</button>
<h2 id="here"></h2>
<script>
var points = [40, 100, 1, 5, 25, 10];
function myFunction() {
points.sort(function(a, b){return a-b});
document.getElementById("here").innerHTML ="Number after Sorting:<br>" +points;
}
</script>
</body>
</html>
Comments
Post a Comment