The most viewed items
<!DOCTYPE html>
<html>
<head>
<title>JavaScript Code Testing</title>
</head>
<body>
<p id = "demo"></p>
<button type = "button" onclick = "jsSort()">Sort</button>
<button type = "button" onclick = "jsReverse()">Reverse</button>
<script>
var cities = ["Yangon", "Mandalay", "Naypyidaw", "Meikhtila", "Bagan"];
document.getElementById("demo").innerHTML = cities.join(" * ");
function jsSort(){
var sort = cities.sort().join(" * ");
document.getElementById("demo").innerHTML = sort;
}
function jsReverse(){
var reverse = cities.reverse().join(" * ");
document.getElementById("demo").innerHTML = reverse;
}
</script>
</body>
</html>
No comment to show.