Giter VIP home page Giter VIP logo

js-exercises's Introduction

JS-exercises

  1. Exercise: Callback functions, and the Date object

Follow the instructions below to create a script that will include a function that determines if a month includes any public holidays, and another that logs the holidays of the current month.

  1. Write a function called logItems that accepts one parameter, itemsToLog . Within the function, loop over itemsToLog and use console.log to output each one.
  2. Write a function called checkHolidaysInMonth that accepts three parameters, monthToCheck , allPublicHolidays , and callWithHolidays . Use a console.log statement within the checkHolidaysInMonth function that outputs "Checking holidays for month X", where X is the value of monthToCheck .
  3. Within checkHolidaysInMonth , write a conditional that determines whether the publicHolidays parameter contains an attribute matching the value of the month parameter. If the monthToCheck does match an attribute in the allPublicHolidays object, assign the value of the attribute to a variable holidays within the conditional.
  4. Call the callWithHolidays parameter as a callback within the conditional from the previous step, using the holidays variable as the itemsToLog .
  5. Test the checkHolidaysInMonth by calling it with the parameters 4 , holidaysInVaud , and logItems , i.e. the month May, the object representing public holidays in Vaud, and the function that will be executed as a callback.
  6. Use the Date object to get the current month in number format. Call checkHolidaysInMonth again but use the current month instead of the static value from 5.

js-exercises's People

Contributors

dangerrg avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.