From df8c260e24eb9208e596b90ce2f288783b96b16e Mon Sep 17 00:00:00 2001 From: Rex Tsou Date: Fri, 24 Apr 2020 15:53:11 +0800 Subject: [PATCH] fix: prevent variable being declared globally Fixes #238 --- js/predictions.js | 4 ++-- js/scripts.js | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/js/predictions.js b/js/predictions.js index 359d329..9c81e3a 100644 --- a/js/predictions.js +++ b/js/predictions.js @@ -882,8 +882,8 @@ class Predictor { }); let global_min_max = []; - for (var day = 0; day < 14; day++) { - prices = { + for (let day = 0; day < 14; day++) { + const prices = { min: 999, max: 0, } diff --git a/js/scripts.js b/js/scripts.js index 1bd48b8..6e7c384 100644 --- a/js/scripts.js +++ b/js/scripts.js @@ -208,9 +208,8 @@ const getPricesFromQuery = function (param) { }; const getPreviousFromQuery = function () { - /* Check if valid prices are entered. Exit immediately if not. */ - prices = getPricesFromQuery("prices"); + const prices = getPricesFromQuery("prices"); if (prices == null) { return null; }