Home Answers Viewqa JavaScriptQuestions how i can print the elements before a spicific value in array queue?

 
 


afnan
how i can print the elements before a spicific value in array queue?
1 Answer(s)      2 years and 4 months ago
Posted in : JavaScript Questions

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 Pages:

Ask Questions?

If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.

Ask your questions, our development team will try to give answers to your questions.