"found large and small number"
Bootstrap 4.0.0 Snippet by Hituat

<link href="//maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" rel="stylesheet" id="bootstrap-css"> <script src="//maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"></script> <script src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> <!------ Include the above in your HEAD tag ----------> <!DOCTYPE html> <html> <body> <h2>JavaScript Array using samllest and largest number</h2> Given Array is :[<span id="demo"></span>]<br><br> <button onclick="method1('small')">click for small number</button> <button onclick="method1()">click for large number</button><br><br> <span id="srt"></span><br><br> Large number is :<span id="large"></span><br><br> Small number is :<span id="small"></span><br><br> <script> var num=[10,2,30,456,15,9]; var len=num.length; document.getElementById("demo").innerHTML=num; function method1(fn){ if(fn=='small'){ for(var i=0;i<len-1;i++){ for(var j=0;j<len-1;j++){ if(num[j]>num[j+1]){ c=num[j+1]; num[j+1]=num[j]; num[j]=c; } } } //document.getElementById("srt").innerHTML=num; document.getElementById("small").innerHTML=num[0]; } else{ for(var i=0;i<len-1;i++){ for(var j=0;j<len-1;j++){ if(num[j]>num[j+1]){ c=num[j+1]; num[j+1]=num[j]; num[j]=c; } } } //document.getElementById("srt").innerHTML=num; document.getElementById("large").innerHTML=num[len-1]; } } </script> </body> </html>

Related: See More


Questions / Comments: