esercizi js
This commit is contained in:
53
js_20.html
Normal file
53
js_20.html
Normal 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>
|
||||
Reference in New Issue
Block a user