Skip to content

Commit 4a64f00

Browse files
v2.2
1 parent 0a217ff commit 4a64f00

File tree

6 files changed

+194
-100
lines changed

6 files changed

+194
-100
lines changed

01-Fundamentals-Part-1/final/script.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,6 @@ console.log(String(23), 23);
246246
console.log('I am ' + 23 + ' years old');
247247
console.log('23' - '10' - 3);
248248
console.log('23' / '2');
249-
console.log('23' > '18');
250249
251250
let n = '1' + 1; // '11'
252251
n = n - 1;
@@ -445,7 +444,6 @@ console.log(drink2);
445444
console.log(`I like to drink ${age >= 18 ? 'wine 🍷' : 'water 💧'}`);
446445
*/
447446

448-
449447
////////////////////////////////////
450448
// Coding Challenge #4
451449

@@ -467,4 +465,4 @@ GOOD LUCK 😀
467465
const bill = 430;
468466
const tip = bill <= 300 && bill >= 50 ? bill * 0.15 : bill * 0.2;
469467
console.log(`The bill was ${bill}, the tip was ${tip}, and the total value ${bill + tip}`);
470-
*/
468+
*/

09-Data-Structures-Operators/final/script.js

+33-2
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ const restaurant = {
4848
},
4949
};
5050

51-
/*
5251
///////////////////////////////////////
5352
// String Methods Practice
5453

@@ -70,7 +69,6 @@ for (const flight of flights.split('+')) {
7069
)} ${getCode(from)} ${getCode(to)} (${time.replace(':', 'h')})`.padStart(36);
7170
console.log(output);
7271
}
73-
*/
7472

7573
///////////////////////////////////////
7674
// Coding Challenge #4
@@ -673,6 +671,39 @@ team1 < team2 && console.log('Team 1 is more likely to win');
673671
team1 > team2 && console.log('Team 2 is more likely to win');
674672
675673
674+
///////////////////////////////////////
675+
// Logical Assignment Operators
676+
const rest1 = {
677+
name: 'Capri',
678+
// numGuests: 20,
679+
numGuests: 0,
680+
};
681+
682+
const rest2 = {
683+
name: 'La Piazza',
684+
owner: 'Giovanni Rossi',
685+
};
686+
687+
// OR assignment operator
688+
// rest1.numGuests = rest1.numGuests || 10;
689+
// rest2.numGuests = rest2.numGuests || 10;
690+
// rest1.numGuests ||= 10;
691+
// rest2.numGuests ||= 10;
692+
693+
// nullish assignment operator (null or undefined)
694+
rest1.numGuests ??= 10;
695+
rest2.numGuests ??= 10;
696+
697+
// AND assignment operator
698+
// rest1.owner = rest1.owner && '<ANONYMOUS>';
699+
// rest2.owner = rest2.owner && '<ANONYMOUS>';
700+
rest1.owner &&= '<ANONYMOUS>';
701+
rest2.owner &&= '<ANONYMOUS>';
702+
703+
console.log(rest1);
704+
console.log(rest2);
705+
706+
676707
///////////////////////////////////////
677708
// The Nullish Coalescing Operator
678709
restaurant.numGuests = 0;

11-Arrays-Bankist/final/script.js

+23-9
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,21 @@ console.log([...arr, ...arr2]);
275275
console.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
280295
const movements = [200, 450, -400, 3000, -650, -130, 70, 1300];
@@ -609,7 +624,7 @@ console.log(movements);
609624
const arr = [1, 2, 3, 4, 5, 6, 7];
610625
console.log(new Array(1, 2, 3, 4, 5, 6, 7));
611626
612-
// Empty arrays + fill method
627+
// Emprty arrays + fill method
613628
const x = new Array(7);
614629
console.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);
657672
const numDeposits1000 = accounts
658673
.flatMap(acc => acc.movements)
659674
.reduce((count, cur) => (cur >= 1000 ? ++count : count), 0);
660-
675+
661676
console.log(numDeposits1000);
662677

663-
// Prefixed ++ operator
678+
// Prefixed ++ oeprator
664679
let a = 10;
665680
console.log(++a);
666681
console.log(a);
@@ -676,29 +691,28 @@ const { deposits, withdrawals } = accounts
676691
},
677692
{ deposits: 0, withdrawals: 0 }
678693
);
679-
694+
680695
console.log(deposits, withdrawals);
681696

682697
// 4.
683698
// this is a nice title -> This Is a Nice Title
684699
const 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

698713
console.log(convertTitleCase('this is a nice title'));
699714
console.log(convertTitleCase('this is a LONG title but not too long'));
700715
console.log(convertTitleCase('and here is another title with an EXAMPLE'));
701-
*/
702716

703717
///////////////////////////////////////
704718
// Coding Challenge #4

0 commit comments

Comments
 (0)