Created
December 13, 2025 17:14
-
-
Save davidystephenson/eb60fd6be733d2d5ce28b0f8245800f3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <h1 id="country">What country do you live in?</h1> | |
| <script> | |
| const heading = document.getElementById('country') | |
| // const localCountry = localStorage.getItem('country') | |
| // console.log('localCountry', localCountry) | |
| const sessionCountry = sessionStorage.getItem('country') | |
| if (sessionCountry) { | |
| heading.innerHTML = sessionCountry | |
| } else { | |
| const country = prompt('What country to do you live in?') | |
| console.log('promptCountry', country) | |
| heading.innerHTML = country | |
| // localStorage.setItem('country', country) | |
| sessionStorage.setItem('country', country) | |
| } | |
| // localStorage.clear('country') | |
| // async function upload () { | |
| // console.log('Uploading...') | |
| // const data = { message: 'hello' } | |
| // const body = JSON.stringify(data) | |
| // const init = { | |
| // method: 'POST', | |
| // body | |
| // } | |
| // const response = await fetch('http://test.com', init) | |
| // const responseData = await response.json() | |
| // console.log(responseData) | |
| // } | |
| // async function download () { | |
| // console.log('Downloading...') | |
| // const response = await fetch('https://swapi.dev/api/people/1/') | |
| // const data = await response.json() | |
| // console.log('data:', data) | |
| // } | |
| // download() | |
| // On your marks - 2000 | |
| // Ready... - 1000 | |
| // Set... - 3000 | |
| // Go! - 5000 | |
| // Race over! | |
| // function delay (ms) { | |
| // return new Promise((resolve) => { | |
| // setTimeout(resolve, ms) | |
| // }) | |
| // } | |
| // async function race () { | |
| // console.log('On your marks...') | |
| // await delay(2000) | |
| // console.log('Ready...') | |
| // await delay(1000) | |
| // console.log('Set...') | |
| // await delay(3000) | |
| // console.log('Go!') | |
| // await delay(5000) | |
| // console.log('Race over') | |
| // return 1 | |
| // } | |
| // async function test () { | |
| // console.log('before race') | |
| // const result = await race() | |
| // console.log('result:', result) | |
| // } | |
| // test() | |
| // delay(2000).then(() => { | |
| // console.log('On your marks...') | |
| // return delay(2000) | |
| // }).then(() => { | |
| // console.log('Ready...') | |
| // return delay(1000) | |
| // }).then(() => { | |
| // console.log('Set...') | |
| // return delay(3000) | |
| // }).then(() => { | |
| // console.log('Go!') | |
| // return delay(5000) | |
| // }).then(() => { | |
| // console.log('Race over') | |
| // }) | |
| // setTimeout(() => { | |
| // console.log('On your marks...') | |
| // setTimeout(() => { | |
| // console.log('Ready...') | |
| // setTimeout(() => { | |
| // console.log('Set...') | |
| // setTimeout(() => { | |
| // console.log('Go!') | |
| // setTimeout(() => { | |
| // console.log('Race over!') | |
| // }, 5000) | |
| // }, 3000) | |
| // }, 1000) | |
| // }, 2000) | |
| // }, 2000) | |
| </script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment