Sort by

recency

|

212 Discussions

|

  • + 0 comments
    function getDayName(dateString) {
        return  ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"][new Date(dateString).getDay()];
    }``
    

    This is my solution , guess what , it is the easiest solution for this problem.

  • + 0 comments
    function getDayName(dateString) {
        let dayName;
        let days = {
            Sun: "Sunday",
            Mon: "Monday",
            Tue: "Tuesday",
            Wed: "Wednesday",
            Thu: "Thursday",
            Fri: "Friday",
            Sat: "Saturday"
            
        }
        let day  = new Date(dateString)
        let arr = day.toString().split(' ')
        let dayshort = arr[0]
        dayName = days[dayshort]
        
        
        return dayName;
    }
    
  • + 0 comments

    function getDayName(dateString) { let dayName; let days = { Sun: "Sunday", Mon: "Monday", Tue: "Tuesday", Wed: "Wednesday", Thu: "Thursday", Fri: "Friday", Sat: "Saturday"

    }
    let day  = new Date(dateString)
    let arr = day.toString().split(' ')
    let dayshort = arr[0]
    dayName = days[dayshort]
    
    
    return dayName;
    

    }

  • + 1 comment

    Here is a simple solution without using any map or map object.

    let dayName = new Date(dateString).toLocaleDateString(undefined, {weekday: "long"});
    return dayName;
    
  • + 0 comments

    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]; }