Bunty Birthday
the goal of the code to get output using with DateMethods.
input
output
input1
['2000-05-13', 'June 7 2021','03/24/2000']
output1
1
2
input2
['Jan 26 2000','Dec 13 2001, 'Nov 18 2001']
output2
function readLine() {
return inputString[currentLine++];
}
function main() {
const birthdaysList = JSON.parse(readLine().replace(/'/g, '"'));
const buntyBirthday = new Date("2000-06-13");
/* Please do not modify anything above this line */
// Write your code here
}
function readLine() {
return inputString[currentLine++];
}
function main() {
const birthdaysList = JSON.parse(readLine().replace(/'/g, '"'));
const buntyBirthday = new Date("2000-06-13");
/* Please do not modify anything above this line */
let days = 0,
months = 0,
years = 0;
birthdaysList.map(date => {
if (new Date(date).getDate() == buntyBirthday.getDate()) days++
if (new Date(date).getMonth() == buntyBirthday.getMonth()) months++
if (new Date(date).getFullYear() == buntyBirthday.getFullYear()) years++
})
console.log(`Same days: ${days}\nSame months: ${months}\nSame years: ${years}`)
}
Comments
Leave a comment