The most viewed items
<!DOCTYPE html>
<html>
<head>
<title>JavaScript Code Testing</title>
</head>
<body>
<p id = "demo"></p>
<button type = "button" onclick = "findMax()">Find Max</button>
<button type = "button" onclick = "jsReset()">Reset</button>
<button type = "button" onclick = "findMin()">Find Min</button>
<script>
var numbers = [200, 30, 400, 50, 1000, 70, 20, 100];
document.getElementById("demo").innerHTML = numbers.join("<br/>");
function jsMax(arr){
return Math.max.apply(null, arr);
}
function jsMin(arr){
return Math.min.apply(null, arr);
}
function findMax(){
document.getElementById("demo").innerHTML = jsMax(numbers);
}
function findMin(){
document.getElementById("demo").innerHTML = jsMin(numbers);
}
function jsReset(){
document.getElementById("demo").innerHTML = numbers.join("<br />");
}
</script>
</body>
</html>
No comment to show.