File tree Expand file tree Collapse file tree 1 file changed +7
-9
lines changed
site/content/examples/7guis-flight-booker Expand file tree Collapse file tree 1 file changed +7
-9
lines changed Original file line number Diff line number Diff line change 1
1
<script >
2
2
const tomorrow = new Date (Date .now () + 86400000 );
3
3
4
- const tomorrowAsString = [
4
+ let start = [
5
5
tomorrow .getFullYear (),
6
6
pad (tomorrow .getMonth () + 1 , 2 ),
7
7
pad (tomorrow .getDate (), 2 )
8
8
].join (' -' );
9
9
10
- let start = tomorrowAsString;
11
- let end = tomorrowAsString;
10
+ let end = start;
12
11
let isReturn = false ;
13
12
14
- const startDate = () => convertToDate (start);
15
- const endDate = () => convertToDate (end);
16
-
13
+ $: startDate = convertToDate (start);
14
+ $: endDate = convertToDate (end);
17
15
18
16
function bookFlight () {
19
17
const type = isReturn ? ' return' : ' one-way' ;
20
18
21
- let message = ` You have booked a ${ type} flight, leaving ${ startDate () .toDateString ()} ` ;
19
+ let message = ` You have booked a ${ type} flight, leaving ${ startDate .toDateString ()} ` ;
22
20
if (type === ' return' ) {
23
- message += ` and returning ${ endDate () .toDateString ()} ` ;
21
+ message += ` and returning ${ endDate .toDateString ()} ` ;
24
22
}
25
23
26
24
alert (message);
57
55
58
56
<button
59
57
on:click ={bookFlight }
60
- disabled =" {isReturn && (startDate () >= endDate () )}"
58
+ disabled =" {isReturn && (startDate >= endDate )}"
61
59
>book</button >
You can’t perform that action at this time.
0 commit comments