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

53
js_20.html Normal file
View File

@@ -0,0 +1,53 @@
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
</head>
<body>
<script>
function costruisci (input){
if (input == "somma"){
f = function (a,b){
if (!isNaN(a) && !isNaN(b))
return a + b;
return null
}
return f;
} else if (input == "molt"){
f = function (a,b){
if (!isNaN(a) && !isNaN(b))
return a * b;
return null
}
return f;
}else
return null;
}
document.writeln((costruisci("somma"))(10,20));
document.writeln((costruisci("molt"))(10,20));
</script>
</body>
</html>