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']}…
<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']}…
<script> //filter(current, index, array) const movements = [200, 450, -400, 3000, -650, -130, 70, 5000]; const deposits = movements.filter((mov) => mov > 0); //arrow method function console.log(deposits); const withdraw =…
const secureBooking = function () { let passengerCount = 0; return function () { passengerCount++; console.log(`${passengerCount} passengers`); }; }; const booker = secureBooking(); booker(); booker(); booker(); console.dir(booker); /////////////////////////////////////// // More…
const runOnce = function () { console.log('This will never run again'); }; runOnce(); // IIFE (function () { console.log('This will never run again'); const isPrivate = 23; })(); // console.log(isPrivate);…
<style> *{ margin:0; padding:0; } li{ list-style: none; } #box{ width:250px; border:1px solid black; margin:20px; } #box h3{ border:1px solid black; height: 30px; line-height:30px; padding-left: 20px; background-color: skyblue; } #box…
<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…
<script> const airasia = { airline: 'Airasia', iataCode: 'DX', bookings: [], //book: function(){} //New Syntax As Below book(flightNum, name){ console.log(`${name} booked a seat on ${this.airline} flight ${this.iataCode}${flightNum}`); }, }; airasia.book(2678,…
<script> const oneWord = function (str){ return str.replace(/ /g,'').toLowerCase(); }; const upperFirstWord = function (str) { const [first, ...others] = str.split(' '); return [first.toUpperCase(), ...others].join(' '); }; //Higher-Order function const…
<script> const flight = 'LH123'; const amanda = { name: 'Amanda Law', passport: 54124092 } const checkIn = function(flightNum, passenger){ flightNum = 'LH999'; passenger.name = 'Mr.' + passenger.name; if(passenger.passport ===…