-
-
Save Spirecool/97c767faafd057db15bfd67d9ab92711 to your computer and use it in GitHub Desktop.
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
// Fonction pour calculer un age | |
function calculateAge(yearOfBirth) { // pour calculer l'age il faut une année de naissance | |
let age = 2020 - yearOfBirth | |
console.log(age) //on aurait pu mettre le ocnsole.log après la déclaration de la constante ageBob | |
return age | |
} | |
const ageBob = calculateAge(1985); | |
// maintenant on va utiliser des fonctions imbriquées | |
function anneesAvantLaRetraite(name, yearOfBirth) { | |
let age = calculateAge(yearOfBirth) | |
let retraite = 65 - age; | |
console.log(name + ' va partir en retraite dans ' + retraite + ' ans'); | |
return retraite | |
} | |
anneesAvantLaRetraite('Bob' , 1989); // affiche 34 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment