Published in : 2022-03-02
What did I miss?
var userJoinedDate = new Date().setDate(3);document.getElementById("result").innerHTML = userJoinedDate.getDate();
it returns error `Uncaught TypeError: undefined is not a function`.
Join our community and get the chance to solve your code issues & share your opinion with usSign up Now
Rakshit Date : 2022-03-05
Reason for issue: When you use setDate, it modified the object and so it will return undefined, as it wasn't defined internally.
When you change the day, you could copy userJoinedDate object and then change it to the anotherDate name.
Try in this way, it will never give undefined error.
Shilpa Date : 2022-03-06
Thanks, It worked! Never thought of such a solution!