1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
| <!DOCTYPE html>
<html lang="fr" dir="ltr">
<head>
<meta http-equiv="cache-control" content="public, max-age=60">
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="author" content="Daniel Hagnoul">
<title>Test</title>
<style>
</style>
<script>
'use strict';
document.addEventListener( 'DOMContentLoaded', ev => {
}, false );
window.addEventListener( 'load', ev => {
{
let calculTva = {
tva : 6,
montantTva( n ){
return Math.round( n * 100 * this.tva / 100 ) / 100;
},
montantTotal( n ){
return Math.round( n * 100 * ( 1.0 + this.tva / 100 ) ) / 100;
},
calcul( n ){
console.log( " montant hors TVA = ", n );
console.log( " montant de la TVA = ", calculTva.montantTva( n ) );
console.log( " montant Total = ", calculTva.montantTotal( n ) );
}
};
calculTva.calcul( 715.45 );
calculTva.tva = 20;
calculTva.calcul( 715.45 );
}
{
function doubler( n ){
console.log( n );
if ( n < 100 ){
n *= 2;
doubler( n ); // appel récursif !
} else {
console.log( "resultat final = ", n ); // 128
r = n;
}
}
let r = 1;
doubler( r );
console.log( r ); // 128
}
}, false );
</script>
</head>
<body>
<main>
</main>
</body>
</html> |
Partager