Created
May 3, 2018 14:09
-
-
Save glenux/45d929a53b5969026d8103a0ce5943a1 to your computer and use it in GitHub Desktop.
// source https://jsbin.com/tanawen
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Exercice - prixttc (10 min) | |
=========================== | |
A. Ecrire une fonction 'prixTTC' qui: | |
- prend un parametre numérique (prix_ht) | |
- calcule le prix TTC (rappel: la TVA est de 20%) | |
- retourne le prix TTC. | |
B. Vérifier votre fonction avec le programme suivant : | |
(on parle de "suite de test"); | |
console.log("Test1 : " + (prixTTC(100) == 120)); | |
console.log(prixTTC(100)); // on attend 120 | |
console.log(prixTTC(20)); // on attend 24 | |
*/ | |
function prixTTC(prix_ht) { | |
var prix_ttc; | |
prix_ttc = (prix_ht * 1.20); | |
return prix_ttc; | |
// La version qui suit aurait suffit : | |
// return (prix_ht * 1.20) ; | |
} | |
console.log("Test1 : " + (prixTTC(100) == 120)); | |
console.log(prixTTC(100)); // on attend 120 | |
console.log(prixTTC(20)); // on attend 24 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment