I have the following script:
I want my app to access and remember for the second launch one of this pages:
This is how I tried but it’s not working.
<script>
if (localStorage.getItem("0") === null) {
//do nothing
}
else if(localStorage.getItem("1")===null{
}
else if(localStorage.getItem("2")===null{
}
else if(localStorage.getItem("3")===null{
}
else if(localStorage.getItem("0") !==null){
window.location = "cosmote.html"
}
else if(localStorage.getItem("1") !==null){
window.location = "germanos.html"
}
else if(localStorage.getItem("2") !==null){
window.location = "zapp.html"
}
else if(localStorage.getItem("3") !==null){
window.location = "sunlight.html"
}
</script>
Would you not be better, sotring the last page value in one local storage area?
Then doing one call e.g
localStorage.getItem("lastPage");Then doing a switch or if else again, this will save mutliple accesses to local storage.
This will make it more efficent and readable, or if this isnt the case at least use an object and a value for each page.