Skip to content

Commit

Permalink
Remove duplicates before calculating number of species
Browse files Browse the repository at this point in the history
  • Loading branch information
mikkohei13 committed Sep 9, 2024
1 parent 3d6c193 commit 9a7b01a
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion app/templates/form_challenge100.html
Original file line number Diff line number Diff line change
Expand Up @@ -160,11 +160,13 @@
// Select all date inputs with the class 'species_date'
var dateFields = document.querySelectorAll('#challenge input[type="date"]');
var filledCount = 0;
var uniqueIds = new Set(); // Create a Set to store unique field IDs

// Loop through each date field to check if it's filled
dateFields.forEach(function(field) {
if (field.value) { // If the field is not empty (i.e., has a value)
if (field.value && !uniqueIds.has(field.id)) { // If the field is filled and ID is not a duplicate
filledCount++;
uniqueIds.add(field.id); // Add the ID to the Set to prevent duplicates
}
});

Expand Down

0 comments on commit 9a7b01a

Please sign in to comment.