-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlocalStorage.js
More file actions
23 lines (18 loc) · 763 Bytes
/
localStorage.js
File metadata and controls
23 lines (18 loc) · 763 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
// Zapisywanie do Local Storage. // Save to Local Storage.
localStorage.setItem("title", "Game Cookie Monster");
localStorage.setItem("score cookie", "24");
localStorage.setItem("name", "Sid");
localStorage.setItem("rank", "Blue");
// Odczytywanie z Local Storage. // Reading from Local Storage.
const titleGame = localStorage.getItem("title");
console.log(titleGame);
// Usuwanie elementów z Local Storage. // Deleting items from Local Storage.
localStorage.removeItem("title");
// Usuwanie wszystkich elementów z Local Storage. // Removing all items from Local Storage.
// localStorage.clear();
if (confirm("Are you sure you want to delete the data?")) {
localStorage.clear();
alert("Data has been deleted");
} else {
alert("Failed to clear data");
}