From 5b29bc411c8058f155a24ab2743745ac78dfca79 Mon Sep 17 00:00:00 2001 From: Igor Kulman Date: Sun, 21 Sep 2025 22:22:32 +0200 Subject: [PATCH] Fix variable naming and bounds check in displayRate function --- src/components/services/Transmission.vue | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/components/services/Transmission.vue b/src/components/services/Transmission.vue index 85afeaa..ca3304b 100644 --- a/src/components/services/Transmission.vue +++ b/src/components/services/Transmission.vue @@ -35,16 +35,16 @@ const units = ["B", "KB", "MB", "GB"]; // value for which we have a unit is determined. Return the value with // up to two decimals as a string and unit/s appended. const displayRate = (rate) => { - let i = 0; + let unitIndex = 0; - while (rate > 1000 && i < units.length) { + while (rate > 1000 && unitIndex < units.length - 1) { rate /= 1000; - i++; + unitIndex++; } return ( Intl.NumberFormat(undefined, { maximumFractionDigits: 2 }).format( rate || 0, - ) + ` ${units[i]}/s` + ) + ` ${units[unitIndex]}/s` ); };