Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Handles the local storage in the UI
- class Storage {
- static getPlayers() {
- let players;
- if (localStorage.getItem('players') === null) {
- players = [];
- } else {
- players = JSON.parse(localStorage.getItem('players'));
- }
- return players;
- }
- static addSoccerPlayer(player) {
- const players = Storage.getPlayers();
- players.push(player);
- localStorage.setItem('players', JSON.stringify(players));
- }
- static removeSoccerPlayer(jerseynumber) {
- const players = Storage.getPlayers();
- players.forEach((player, index) => {
- if (player.jerseynumber === jerseynumber) {
- players.splice(index, 1);
- }
- });
- localStorage.setItem('players', JSON.stringify(players));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement