esercizi js

This commit is contained in:
2014-11-30 18:46:24 +01:00
parent b2e9b46742
commit c30036a3bc
11 changed files with 597 additions and 27 deletions

49
js_10.html Normal file
View File

@@ -0,0 +1,49 @@
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
</head>
<body>
<script>
sum=[];
i="beg";
while (true) {
i = prompt("Insert n or end");
if (i == "end")
break;
for (;!i || isNaN(i) ;)
i= prompt("Err.Insert n");
sum.push(parseFloat(i));
}
tot=0;
for (i=0;i<sum.length;i++){
tot = tot + sum[i];
}
document.writeln("<table>");
for (i=0;i<sum.length;i++){
document.writeln("<tr><td>" + sum[i] +"</td></tr>");
}
document.writeln("<tr><td>" + tot / sum.length +"</td></tr>");
document.writeln("</table>");
</script>
</body>
</html>