We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Day 6: JavaScript Dates
Day 6: JavaScript Dates
Sort by
recency
|
212 Discussions
|
Please Login in order to post a comment
This is my solution , guess what , it is the easiest solution for this problem.
function getDayName(dateString) { let dayName; let days = { Sun: "Sunday", Mon: "Monday", Tue: "Tuesday", Wed: "Wednesday", Thu: "Thursday", Fri: "Friday", Sat: "Saturday"
}
Here is a simple solution without using any map or map object.
function getDayName(dateString) { let dayName; // Write your code here let dayweeks = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"] dayName = new Date(dateString).getDay() return dayweeks[dayName]; }