Skip to content

Commit

Permalink
Update script.js
Browse files Browse the repository at this point in the history
Add space to big numbers
Moved toFixed function
  • Loading branch information
20syldev committed Apr 27, 2024
1 parent a23b23b commit 824ea0c
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/js/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ function searchUsername(username, target) {
get(ref(db, 'identifiants/username/' + username)).then(snapshot => {
if (snapshot.exists()) {
const occurrences = snapshot.val().occurrences;
const sum = snapshot.val().sum;
const moyenne = snapshot.val().sum / snapshot.val().occurrences;
const sum = snapshot.val().sum.toFixed(2).replace(/\B(?=(\d{3})+(?!\d))/g, " ");
const moyenne = (snapshot.val().sum / snapshot.val().occurrences).toFixed(2).replace(/\B(?=(\d{3})+(?!\d))/g, " ");
if (occurrences > 1) {
document.getElementById(target).innerHTML = `Apparitions : ${occurrences} fois<br>Montant total : ${sum.toFixed(2)}€<br>Moyenne des montants : ${moyenne.toFixed(2)}€`; // Mettre à jour si apparition > 1
document.getElementById(target).innerHTML = `Apparitions : ${occurrences} fois<br>Montant total : ${sum}€<br>Moyenne des montants : ${moyenne}€`; // Mettre à jour si apparition > 1
}
else {
document.getElementById(target).innerHTML = `Apparition : ${occurrences} fois<br>Montant total : ${sum.toFixed(2)}€<br>Moyenne des montants : ${moyenne.toFixed(2)}€`; // Mettre à jour si apparition = 1
document.getElementById(target).innerHTML = `Apparition : ${occurrences} fois<br>Montant total : ${sum}€<br>Moyenne des montants : ${moyenne}€`; // Mettre à jour si apparition = 1
}
}
});
Expand Down

0 comments on commit 824ea0c

Please sign in to comment.