@@ -275,6 +275,21 @@ console.log([...arr, ...arr2]);
275275console.log(letters.join(' - '));
276276
277277
278+ ///////////////////////////////////////
279+ // The new at Method
280+ const arr = [23, 11, 64];
281+ console.log(arr[0]);
282+ console.log(arr.at(0));
283+
284+ // getting last array element
285+ console.log(arr[arr.length - 1]);
286+ console.log(arr.slice(-1)[0]);
287+ console.log(arr.at(-1));
288+
289+ console.log('jonas'.at(0));
290+ console.log('jonas'.at(-1));
291+
292+
278293///////////////////////////////////////
279294// Looping Arrays: forEach
280295const movements = [200, 450, -400, 3000, -650, -130, 70, 1300];
@@ -609,7 +624,7 @@ console.log(movements);
609624const arr = [1, 2, 3, 4, 5, 6, 7];
610625console.log(new Array(1, 2, 3, 4, 5, 6, 7));
611626
612- // Empty arrays + fill method
627+ // Emprty arrays + fill method
613628const x = new Array(7);
614629console.log(x);
615630// console.log(x.map(() => 5));
@@ -636,7 +651,7 @@ labelBalance.addEventListener('click', function () {
636651
637652 const movementsUI2 = [...document.querySelectorAll('.movements__value')];
638653});
639-
654+ */
640655
641656///////////////////////////////////////
642657// Array Methods Practice
@@ -657,10 +672,10 @@ console.log(bankDepositSum);
657672const numDeposits1000 = accounts
658673 . flatMap ( acc => acc . movements )
659674 . reduce ( ( count , cur ) => ( cur >= 1000 ? ++ count : count ) , 0 ) ;
660-
675+
661676console . log ( numDeposits1000 ) ;
662677
663- // Prefixed ++ operator
678+ // Prefixed ++ oeprator
664679let a = 10 ;
665680console . log ( ++ a ) ;
666681console . log ( a ) ;
@@ -676,29 +691,28 @@ const { deposits, withdrawals } = accounts
676691 } ,
677692 { deposits : 0 , withdrawals : 0 }
678693 ) ;
679-
694+
680695console . log ( deposits , withdrawals ) ;
681696
682697// 4.
683698// this is a nice title -> This Is a Nice Title
684699const convertTitleCase = function ( title ) {
685- const capitalize = str => str[0].toUpperCase() + str.slice(1);
700+ const capitzalize = str => str [ 0 ] . toUpperCase ( ) + str . slice ( 1 ) ;
686701
687702 const exceptions = [ 'a' , 'an' , 'and' , 'the' , 'but' , 'or' , 'on' , 'in' , 'with' ] ;
688703
689704 const titleCase = title
690705 . toLowerCase ( )
691706 . split ( ' ' )
692- .map(word => (exceptions.includes(word) ? word : capitalize (word)))
707+ . map ( word => ( exceptions . includes ( word ) ? word : capitzalize ( word ) ) )
693708 . join ( ' ' ) ;
694709
695- return capitalize (titleCase);
710+ return capitzalize ( titleCase ) ;
696711} ;
697712
698713console . log ( convertTitleCase ( 'this is a nice title' ) ) ;
699714console . log ( convertTitleCase ( 'this is a LONG title but not too long' ) ) ;
700715console . log ( convertTitleCase ( 'and here is another title with an EXAMPLE' ) ) ;
701- */
702716
703717///////////////////////////////////////
704718// Coding Challenge #4
0 commit comments