-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstorage.js
More file actions
32 lines (29 loc) · 731 Bytes
/
storage.js
File metadata and controls
32 lines (29 loc) · 731 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
class Storage {
constructor() {
this.city;
this.country;
this.defaultCity = "Patna";
this.defaultCountry = "IN";
}
getLocationData() {
if (localStorage.getItem("city") === null) {
this.city = this.defaultCity;
} else {
this.city = localStorage.getItem("city");
}
if (localStorage.getItem("country") === null) {
this.country = this.defaultCountry;
} else {
this.country = localStorage.getItem("country");
}
console.log(this.city + " " + this.country);
return {
city: this.city,
country: this.country,
};
}
setLocationData(city, country) {
localStorage.setItem("city", city);
localStorage.setItem("country", country);
}
}