From e050dc67d921cfdca18792489fe48d10be07f25b Mon Sep 17 00:00:00 2001 From: Jiya Agrawal Date: Sat, 12 Jul 2025 22:56:35 +0530 Subject: [PATCH] fix: renamed alert variable to alertBox to avoid conflict with window.alert --- 14-grocery-bud/final/app.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/14-grocery-bud/final/app.js b/14-grocery-bud/final/app.js index 780530c2..0f85e7a5 100644 --- a/14-grocery-bud/final/app.js +++ b/14-grocery-bud/final/app.js @@ -1,7 +1,7 @@ // ****** select items ********** const form = document.querySelector(".grocery-form"); -const alert = document.querySelector(".alert"); +const alertBox = document.querySelector(".alert"); //renamed const grocery = document.getElementById("grocery"); const submitBtn = document.querySelector(".submit-btn"); const container = document.querySelector(".grocery-container"); @@ -75,15 +75,15 @@ function addItem(e) { } // display alert function displayAlert(text, action) { - alert.textContent = text; - alert.classList.add(`alert-${action}`); - // remove alert + alertBox.textContent = text; + alertBox.classList.add(`alert-${action}`); setTimeout(function () { - alert.textContent = ""; - alert.classList.remove(`alert-${action}`); + alertBox.textContent = ""; + alertBox.classList.remove(`alert-${action}`); }, 1000); } + // clear items function clearItems() { const items = document.querySelectorAll(".grocery-item");