momo3141

main.js

Jan 9th, 2023
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. // import moment module
  2. import moment from 'moment';
  3. // import logger module
  4. import logger from './logger.js';
  5.  
  6. // do not remove this line. Still, if you want google it :)
  7. moment.suppressDeprecationWarnings = true;
  8.  
  9. // print current date using moment and logger.info
  10.  
  11. logger.info(moment().format('D, MMM')) //info: 9, Jan
  12.  
  13. const dates = ["1995-12-25", "2020W065", "js-cohort", "2020-W06-5"];
  14. // Parse the array and logs success when date is valid or error when invalid using the logger
  15. dates.forEach( (date) => {
  16. if (moment(date).isValid()) {
  17. return logger.success(moment(date));
  18. } else {
  19. return logger.error(moment(date));
  20. }
  21. });
  22. /**for (let date of dates){
  23. if(moment(date).isValid()){
  24. logger.success(moment(date));
  25. } else {
  26. logger.error(moment(date));
  27. }
  28. }*/
  29.  
Advertisement
Add Comment
Please, Sign In to add comment