Skip to content

Commit aab275e

Browse files
committed
fix: try/catch
1 parent 0d24a8b commit aab275e

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

066-meal finder/script.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,12 @@ const singleMealElement = document.getElementById("single-meal");
77
const searchHistory = document.getElementById("search-history");
88

99
let lastSearch = false;
10-
let searches = JSON.parse(localStorage.getItem("searches") || "[]");
10+
let searches;
11+
try {
12+
searches = JSON.parse(localStorage.getItem("searches")) || [];
13+
} catch (e) {
14+
searches = [];
15+
}
1116

1217
// Implement a Search History
1318
function renderSearchHistory() {

0 commit comments

Comments
 (0)