»
AnglaisFrançaisVietnamien

Imprimer - Lagrest, plus petite et la somme - JavaScriptBank.com

Version complète: jsB@nk » Calcul » Math » Lagrest, plus petite et la somme
URL: https://www.javascriptbank.com/lagre-small-number.html

Lagrest, plus petite et la somme © JavaScriptBank.comCet JavaScript array utilise pour stocker les valeurs tha utilisateurs soumettent alors alerter le plus grand, le plus petit nombre et la somme des nombres.

Version complète: jsB@nk » Calcul » Math » Lagrest, plus petite et la somme
URL: https://www.javascriptbank.com/lagre-small-number.html



JavaScript
<script language="javascript">arr=new Array() var i=0,value=0,flag=falsevar sum=0function aj(a){flag=truevar check=aarr[i]=eval(a)sum=sum+arr[i]i++document.f1.t1.value=""document.f1.t1.focus()}function j(){var n=arr.length,small=arr[n-1],large=arr[0]for(i=0;i<n;i++){if(arr[i]>large)large=arr[i]if(arr[i]<small)small=arr[i]}if(!flag){large=0;small=0;}alert(large+"  is the largest among the numbers"+"\n"+small+"  is the smallest among the numbers")alert("The sum of the numbers is  "+sum)}</script><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->


HTML
<form name="f1" style="text-align: left; width: 40%;">Type numbers one by one as much you wish.....<br>Press &quot;OK&quot; after every number...<br>  Press &quot;RESULT&quot; to see which number is smallest and which is largest..... and the total sum of all numbers<br><input type="text" name="t1"><input type="button" value=" OK " onClick="aj(f1.t1.value)">  <br><input type="button" value=" RESULT " onClick="j()"></form><!--    This script downloaded from www.JavaScriptBank.com    Come to view and download over 2000+ free javascript at www.JavaScriptBank.com-->