Skip to content

10 JavaScript Challenges - Is the date today #8

@CelticKnight

Description

@CelticKnight

This is a Github issue template. You will need to replace all lines marked with REPLACE. If you want to see an example issue, please refer to this one. While I will try to get to your question as quickly as possible, I am creating this series for free and therefore don't always have a ton of free time. Thanks for your understanding!

What video or post URL is your question regarding?

10 Beginner(ish) Javascript Code wars

If it is a YouTube video, what timestamp are you asking about?

1:04:59

What is your question?

I am having trouble with the code below it fails the kata with tomorrows date and Yesterdays date and I cannot see the problem. It works on my local webage showing a True result and if I change the nowDay code by putting a +1 or -1 to it I get a false:
'''
function isToday(date) {
//Code goes here

let todayMonth = date.getMonth(); //indexed 0->11
let todayDay = date.getDay(); //also indexed 0-6
let todayYear = date.getFullYear(); //nb: getFullYear

const currDate = new Date();

let currMonth = currDate.getMonth(); //indexed 0->11
let currDay = currDate.getDay(); //also indexed 0-6
let currYear = currDated.getFullYear(); //nb: getFullYear

if( (todayDay === currDay) && (todayMonth === currMonth) && (todayYear === currYear) ){
console.log(true);
return true;
}
else{
console.log(false);
return false;
}
}
'''

It passes the first series of test but when I went to "Attempt" that it falied in "Should work for some edge cases". Again, I don't know why when it works on my local webpage.

Thankyou and Regards.
Vaughan

Metadata

Metadata

Assignees

Labels

questionFurther information is requested

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions