Sort by

recency

|

211 Discussions

|

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

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