Creating Dates

1. const new = new Date(); console.log(now); => current time; 2. console.log(new Date('December 24, 2015')); => Thu Dec 24 2015 00:00:00 GMT+0000 3. console.log(new Date(2031,10,11,12,12,10)); 4. console.log(new Date(0)); => Thu…

Working With BigInt

console.log(Number.MAX_SAFE_INTEGER); => 9007199254740991 //When facing large numbers that are bigger than above number, Js runs into some problems. How to solve? Using BigInt console.log(BigInt(124623786189682165785218589)); => 124623786189682165785218589n //Or console.log(124623786189682165785218589n); => 124623786189682165785218589n…

Math & Rounding

console.log(Math.sqrt(25)); => 5 console.log(25 ** (1/2)); => 5 console.log(8 ** (1/3)); => 2 console.log(Math.max(5,18,23,11,2)); => 23 console.log(Math.min(5,18,23,11,2)); => 2 //Make a function that can generate random number between min &…

Arrays Challenge 4

<script> const dogs = [ {weight: 22, curFood: 250, owners: ['Alice', 'Bob']}, {weight: 8, curFood: 200, owners: ['Matilda']}, {weight: 13, curFood: 275, owners: ['Sarah','John']}, {weight: 32, curFood: 340, owners: ['Michael']}…

Closure

const secureBooking = function () { let passengerCount = 0; return function () { passengerCount++; console.log(`${passengerCount} passengers`); }; }; const booker = secureBooking(); booker(); booker(); booker(); console.dir(booker); /////////////////////////////////////// // More…