diff --git a/metar.html b/metar.html index a276588..9aca05d 100644 --- a/metar.html +++ b/metar.html @@ -825,15 +825,15 @@ return; } - let metarIndex = -1; + let metarIndex; + // If an ID is provided, try to find it. if (id !== undefined) { metarIndex = metars.findIndex(m => m.line === id); } - if (metarIndex === -1) { - // Bias random selection towards the more interesting (higher-scored) METARs. - // Math.random() * Math.random() skews distribution towards 0. + // If no ID was provided, or the ID was not found, pick a random METAR. + if (id === undefined || metarIndex === -1) { const randomSortedIndex = Math.floor(Math.random() * Math.random() * sortedMetars.length); const selectedMetar = sortedMetars[randomSortedIndex]; metarIndex = metars.findIndex(m => m.metar === selectedMetar.metar);