From edd29cc2b9827ce3a3446d6f56223e641dd4e91f Mon Sep 17 00:00:00 2001 From: Santhi Ranimekala Date: Sat, 19 Jul 2025 11:40:01 +0530 Subject: [PATCH] Refactor getProject into a function and log project names --- script.js | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/script.js b/script.js index 39019ee6..706af087 100644 --- a/script.js +++ b/script.js @@ -22,14 +22,26 @@ searchBar.addEventListener('keyup', (e) => { displayProjects(filteredProjects); }); -const getProject = fetch('cards.json') +/*const getProject = fetch('cards.json') .then(response => response.json()) .then(data => { projects = data; displayProjects(projects) console.log(projects) +});*/ +function getProject() { + fetch('cards.json') + .then(response => response.json()) + .then(data => { + projects = data; + displayProjects(projects); + projects.forEach(project => { + console.log(project.name); }); + + }); +} const displayProjects = (projects) => { const htmlString = projects