File tree 1 file changed +25
-0
lines changed
09-Data-Structure-Modern-Operators-and-Strings
1 file changed +25
-0
lines changed Original file line number Diff line number Diff line change @@ -341,3 +341,28 @@ btn.addEventListener("click", function convertCase() {
341
341
console . log ( `${ result . padEnd ( 20 ) } ${ "✅" . repeat ( i + 1 ) } ` ) ;
342
342
}
343
343
} ) ;
344
+
345
+ // ----------------------------------------
346
+ // String Methods Exerceise
347
+ // ----------------------------------------
348
+
349
+ const flights =
350
+ "_Delayed_Departure;fao93766109;txl2133758440;11:25+_Arrival;bru0943384722;fao93766109;11:45+_Delayed_Arrival;hel7439299980;fao93766109;12:05+_Departure;fao93766109;lis2323639855;12:30" ;
351
+
352
+ // 🔴 Delayed Departure from FAO to TXL (11h25)
353
+ // Arrival from BRU to FAO (11h45)
354
+ // 🔴 Delayed Arrival from HEL to FAO (12h05)
355
+ // Departure from FAO to LIS (12h30)
356
+
357
+ const getCode = ( str ) => str . slice ( 0 , 3 ) . toUpperCase ( ) ;
358
+
359
+ for ( const flight of flights . split ( "+" ) ) {
360
+ const [ type , from , to , time ] = flight . split ( ";" ) ;
361
+ const output = `${ type . startsWith ( "_Delayed" ) ? "🔴" : "" } ${ type
362
+ . replaceAll ( "_" , " " )
363
+ . trim ( ) } from ${ getCode ( from ) } to ${ getCode ( to ) } (${ time . replace (
364
+ ":" ,
365
+ "h"
366
+ ) } )`. padStart ( 50 ) ;
367
+ console . log ( output ) ;
368
+ }
You can’t perform that action at this time.
0 commit comments