tutorial: move function declaration before reference (#5491)

pull/5559/head
Daniel Power 4 years ago committed by GitHub
parent 10f68289ba
commit 379a4454c1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -1,6 +1,4 @@
<script> <script>
let promise = getRandomNumber();
async function getRandomNumber() { async function getRandomNumber() {
const res = await fetch(`tutorial/random-number`); const res = await fetch(`tutorial/random-number`);
const text = await res.text(); const text = await res.text();
@ -12,6 +10,8 @@
} }
} }
let promise = getRandomNumber();
function handleClick() { function handleClick() {
promise = getRandomNumber(); promise = getRandomNumber();
} }

@ -1,6 +1,4 @@
<script> <script>
let promise = getRandomNumber();
async function getRandomNumber() { async function getRandomNumber() {
const res = await fetch(`tutorial/random-number`); const res = await fetch(`tutorial/random-number`);
const text = await res.text(); const text = await res.text();
@ -12,6 +10,8 @@
} }
} }
let promise = getRandomNumber();
function handleClick() { function handleClick() {
promise = getRandomNumber(); promise = getRandomNumber();
} }

Loading…
Cancel
Save