const affichageNb = document.getElementById("nb_vehicules"); const affichageGéo = document.getElementById("géolocalisation"); const affichageConso = document.getElementById("consommation"); const boutonPlus = document.getElementById("plus"); const boutonMoins = document.getElementById("moins"); const PRIX_GPS = 30; const PRIX_CONSOMMATION = 15; let nbVehicules = 1; let totalargent = 0; function mettreAJourGPS() { affichageNb.textContent = nbVehicules; affichageGéo.textContent = nbVehicules * PRIX_GPS; } function mettreAJourCONSO() { affichageNb.textContent = nbVehicules; affichageConso.textContent = nbVehicules * PRIX_CONSOMMATION; } function mettreAJourTOTAL() { affichageNb.textContent = totalargent; affichageGéo.textContent = totalargent + PRIX_GPS + PRIX_CONSOMMATION; } boutonPlus.addEventListener("click", function () { nbVehicules = nbVehicules + 1; (mettreAJourGPS(), mettreAJourCONSO()); if (nbVehicules > 99) { nbVehicules = nbVehicules - 1; } }); boutonMoins.addEventListener("click", function () { if (nbVehicules > 1) { nbVehicules = nbVehicules - 1; } (mettreAJourGPS(), mettreAJourCONSO()); });