how i can print the elements before a spicific value in array queue?

how i can printall elements befor the spicific value and print this value also

View Answers

January 8, 2011 at 4:05 PM

Hi Friend,

Try this:

<html>
<script>
var arr=new Array();
arr[0]=10;       
arr[1]=20;
arr[2]=30;
arr[3]=40;       
arr[4]=50;
arr[5]=60;
arr[6]=70;       
arr[7]=80;
arr[8]=90;
arr[9]=100;
var i;
var num=window.prompt("Enter array element: ");
document.writeln("The value is: "+num+"<br>");
for(i=0;i<arr.length;i++){
if(arr[i]<num){
document.writeln(arr[i]+"<br>");
}
}
</script>
</html>

Thanks









Related Tutorials/Questions & Answers:
Advertisements