WTAD Practical - 6
Write a JavaScript to remove the highest element from the array and arrange the array in ascending order.
Write a JavaScript to remove the highest element from the array and arrange the array in ascending order.
<HTML>
<html>
<HEAD>
<TITLE>WTAD.practical-6 @iAmLearningHere </TITLE>
</HEAD>
<BODY bgcolor="YellowGreen">
<script language="JavaScript">
var i,size,j,temp;
var arr=new Array();
size=parseInt(prompt("enter the size of array",""));
for(i=0;i<size;i++)
{
arr[i]=parseInt(prompt("enter the element of array",""));
}
document.write("array is:-<br>");
for(i=0;i<size;i++)
{
document.write(arr[i]+", ");
}
for(i=0;i<size;i++)
{
for(j=i+1;j<size;j++)
{
if(arr[i]>arr[j])
{
temp=arr[i];
arr[i]=arr[j];
arr[j]=temp;
}
}
}
document.write("<br><br>sorted array is:-<br>");
for(i=0;i<size;i++)
{
document.write( arr[i] + ", ");
}
document.write("<br><br>after delete large element array is:-<br>");
arr.pop();
for(i=0;i<arr.length;i++)
{
document.write(arr[i]+", ");
}
</script>
</BODY>
</HTML>
<html>
<HEAD>
<TITLE>WTAD.practical-6 @iAmLearningHere </TITLE>
</HEAD>
<BODY bgcolor="YellowGreen">
<script language="JavaScript">
var i,size,j,temp;
var arr=new Array();
size=parseInt(prompt("enter the size of array",""));
for(i=0;i<size;i++)
{
arr[i]=parseInt(prompt("enter the element of array",""));
}
document.write("array is:-<br>");
for(i=0;i<size;i++)
{
document.write(arr[i]+", ");
}
for(i=0;i<size;i++)
{
for(j=i+1;j<size;j++)
{
if(arr[i]>arr[j])
{
temp=arr[i];
arr[i]=arr[j];
arr[j]=temp;
}
}
}
document.write("<br><br>sorted array is:-<br>");
for(i=0;i<size;i++)
{
document.write( arr[i] + ", ");
}
document.write("<br><br>after delete large element array is:-<br>");
arr.pop();
for(i=0;i<arr.length;i++)
{
document.write(arr[i]+", ");
}
</script>
</BODY>
</HTML>
0 comments :