Skip to content

Commit f863a5d

Browse files
committed
fix flight booker example
1 parent a8e0a47 commit f863a5d

File tree

1 file changed

+7
-9
lines changed
  • site/content/examples/7guis-flight-booker

1 file changed

+7
-9
lines changed

site/content/examples/7guis-flight-booker/App.svelte

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,24 @@
11
<script>
22
const tomorrow = new Date(Date.now() + 86400000);
33
4-
const tomorrowAsString = [
4+
let start = [
55
tomorrow.getFullYear(),
66
pad(tomorrow.getMonth() + 1, 2),
77
pad(tomorrow.getDate(), 2)
88
].join('-');
99
10-
let start = tomorrowAsString;
11-
let end = tomorrowAsString;
10+
let end = start;
1211
let isReturn = false;
1312
14-
const startDate = () => convertToDate(start);
15-
const endDate = () => convertToDate(end);
16-
13+
$: startDate = convertToDate(start);
14+
$: endDate = convertToDate(end);
1715
1816
function bookFlight() {
1917
const type = isReturn ? 'return' : 'one-way';
2018
21-
let message = `You have booked a ${type} flight, leaving ${startDate().toDateString()}`;
19+
let message = `You have booked a ${type} flight, leaving ${startDate.toDateString()}`;
2220
if (type === 'return') {
23-
message += ` and returning ${endDate().toDateString()}`;
21+
message += ` and returning ${endDate.toDateString()}`;
2422
}
2523
2624
alert(message);
@@ -57,5 +55,5 @@
5755

5856
<button
5957
on:click={bookFlight}
60-
disabled="{isReturn && (startDate() >= endDate())}"
58+
disabled="{isReturn && (startDate >= endDate)}"
6159
>book</button>

0 commit comments

Comments
 (0)