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…

134. Coding Challenge 1

<script> document.body.append(document.createElement('button')); const poll = { question: 'What is your favourite programming language?', options: ['0:JavaScript', '1:Phyton', '2:Rust', '3:C++'], answers: new Array(4).fill(0), registerNewAnswer(){ const answer = Number(prompt(`${this.question}\n${this.options.join('\n')}\n(Write option number)`)); //Update answer…