Saving Data to Local Storage
You can store data in the userβs local storage (browser) to keep simple game records, for example.
save-local-storage
const save_btn = GUI.getObject("save_btn");
let score = 100;
save_btn.onClick(function() {
localStorage.setItem('game_score', score);
});
You can retrieve data stored in local storage like this
load-game-data
let score = localStorage.getItem("game_score");
π«
However, keep in mind that local storage can be accessed easily by users through developer tools, so itβs not suitable for storing important or sensitive data. Additionally, if users delete site data from their browser, data stored in local storage will also be deleted.