Hi I am a new coder and Im unable to understand my next task.
What Ive done is use local storage to set a value in my web app.
Then my next task was to write said value on my page (This took me hours but finally got it done).
My next task is using Setinterval(or what ever the correct way to solve my problem) to subtract a number (lets use “1” for this example) Every 5 seconds from the local storage value.So basically After I click the button. Value is set and displayed. After another button is click. Every 5 seconds the localstorage is subtraced by 1. I think the code im looking for is similar to this
[CODE]setInterval(“localStorage.test” – 5 ()”,5000);
Im pretty sure this is wrong but I think I may have the sense right idea. Can any one help please?
“My Code”
[CODE]
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
<script type=”text/javascript”>
function setCookie(){
localStorage.test=200; //Sets the value of the localstorage
document.getElementById(‘tested’).innerHTML =localStorage.test; //sets the Id value to storage value to an id
}
</script>
</head>
<body>
<input type=”button” onclick=”setCookie()” value=”SetCookie” />
<b id=’tested’></b>
</body
</html>