Professional Documents
Culture Documents
Assignment 1
Assignment 1
Div: B Batch: A1
ASSIGNMENT :-1
Write a CSMASCRIEPT program that will return 1 if the array is sorted in ascending order ,-1 if it is
sorted in descending order or 0 if it is not sorted.
Code:
<!DOCTYPE html>
<html>
<head>
<style>
.container {
display: flex;
flex-direction: column;
align-items: center;
.input-container {
display: flex;
flex-direction: column;
align-items: center;
margin-bottom: 20px;
input[type="text"] {
margin: 10px;
#result {
width: 200px;
}
</style>
</head>
<body bgcolor="#9FE2BF">
<div class="container">
<div class="input-container">
</div>
</div>
<script>
function checkorder() {
isAscending = false;
isDescending = false;
}
let result;
if (isAscending) {
result = 1;
} else if (isDescending) {
result = -1;
} else {
result = 0;
document.getElementById("result").value = result;
</script>
</body>
</html>
Output:
Ascendind order :
Descending Order:
Unsorted array: