Compteur :
| Solution d'exercice - JavaScriptExercice JavaScript 10 :<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Page de test pour JavaScript</title>
</head>
<body>
<h1>Page de test pour JavaScript</h1>
<script language="javascript" type="text/javascript">
<!--
function sumAll()
{
var index
var sum = 0
for(index = 0; index < arguments.length; ++index)
{
sum += arguments[index]
}
return sum
}
var a = 12
var b = 34
var c = 56
var d = 78
var e = 90
document.write("<pre>")
document.writeln("<u>Définition des variables:</u>")
document.writeln("a = "+a)
document.writeln("b = "+b)
document.writeln("c = "+c)
document.writeln("d = "+d)
document.writeln("e = "+e)
document.writeln("")
document.writeln("<u>Additions:</u>")
document.writeln("Somme de a ("+a+"), b ("+b+") et c ("+c+"): ", sumAll(a, b, c))
document.writeln("Somme de b ("+b+") et d ("+d+"): ", sumAll(b, d))
document.writeln("Somme de a ("+a+"), b ("+b+"), c ("+c+"), d ("+d+") et e ("+e+"): ", sumAll(a, b, c, d, e))
document.writeln("Somme d'aucun élément: ", sumAll())
document.writeln("</pre>")
//-->
</script>
<noscript>
<p align="justify"><font color="red"><b>L'affichage de cette page nécessite l'activation du JavaScript.</b></font></p>
</noscript>
</body>
</html>
Pour voir le résultat, cliquez -> ici <-. |
|
Ce site est optimisé pour Mozilla FireFox. L'affichage n'est pas garanti pour votre navigateur. Pour plus d'informations, cliquez -> ici <-.
© Sébastien Adam 1996 ~ 2010 - http://www.sebastienadam.be/ - Le contenu de ce site est soumis à licence. Gestionnaire du site