In my app, I have a splash screen showing on launch according to code on index.html. However, to prevent it from launching every time the Back button takes one to the index.html page, I set a number in sessionstorage so that if the number is there, it won't launch again as long as it's still in memory. This works fine.

However, I am having it check a value in sessionstorage before a value has been written, so I'm not sure this is "correct" syntax, even though it works. Is there a correct way to do this?

Code:
<script>
function onBodyLoad() {
document.addEventListener("deviceready", onDeviceReady, false);
}

function onDeviceReady() {
// Check session storage to see if splash screen already appeared
 countLaunchImage();
}
function countLaunchImage() {
/* If the value is 0 then it's already displayed. If > 0, then t hasn't yet shown and should display. */
 var name = sessionStorage.getItem("count");
 if (name > 0) { showLaunchImage(); }
}
function showLaunchImage() {
// Show splash screen
navigator.splashscreen.show();
// Set value to 0 after it appears
sessionStorage.setItem("count", "0");
// countLaunchImage() should now see a 0 and not launch next time.
}
setTimeout(function() {
 navigator.splashscreen.hide();
}, 1000);
</script>