Setting Default Parameter
<script> const bookings = []; const createBooking = function(flightNum, numPassengers = 1, price = 199 * numPassengers){ //ES5 Old Way To Set Default //numPassengers = numPassengers || 1; //price =…
123. Coding Challenge 4
Working With Strings <script> document.body.append(document.createElement('textarea')); document.body.append(document.createElement('button')); //const text = document.querySelector('textarea').value; document.querySelector('button').addEventListener('click',function(){ const text = document.querySelector('textarea').value; //console.log(text); const rows = text.split('\n'); //先把一整段分成五段 for (const [i, row] of rows.entries()){ const [first, second]…
119. Coding Challenge 3
SetsMaps : FundamentalMaps : Iteration <script> const game = { team1: 'Bayern Munich', team2: 'Borrussia Dortmund', players: [ [ 'Never', 'Pavard', 'Martinez', 'Alaba', 'Davies', 'Kimmich', 'Goretzka', 'Coman', 'Muller', 'Gnarby', 'Lewandowski',…
114. Coding Challenge 2
For-Of LoopEnhanced Object LiteralsOptional Chaining (?.)Looping Object : Object Key, Value and Entries const game = { team1: 'Bayern Munich', team2: 'Borrussia Dortmund', players: [ [ 'Never', 'Pavard', 'Martinez', 'Alaba',…
109. Coding Challenge 1
Destructuring ArraysDestructuring ObjectsSpread Operator Short Circuiting && and ||Nullish Coalescing Operator (??) <script> const game = { team1: 'Bayern Munich', team2: 'Borrussia Dortmund', players: [ [ 'Never', 'Pavard', 'Martinez', 'Alaba',…