Not a member of Pastebin yet?
                        Sign Up,
                        it unlocks many cool features!                    
                - //6 Exercise: Basic Syntax, Conditional Statements and Loops/More Exercise/03. Next Day.js
 - nextDay1 = (year, month, day) => {
 - 'use strict'
 - let yearNext = year
 - let monthNext = month
 - let dayNext = day
 - if (year <= 99 && year >= 0)
 - yearNext += 1900
 - const isLeapYear = (year) => ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0) ? true : false
 - let months = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31]
 - if (isLeapYear(year))
 - months[1] = 29
 - if (month === 12 && day === 31) {
 - yearNext = ++yearNext
 - monthNext = 1
 - dayNext = 1
 - } else if (day === months[month - 1]) {
 - monthNext = ++month
 - dayNext = 1
 - } else {
 - dayNext = ++day
 - }
 - console.log(`${yearNext}-${monthNext}-${dayNext}`)
 - }
 
Advertisement
 
                    Add Comment                
                
                        Please, Sign In to add comment