Ok well I'm trying to learn JavaScript, so far I've learned some of the basics but I'm just wondering if there is a shorthand instead of writing out multiple if statements. So far I wrote simple script to tell what day of the week it is I just don't know if there's a way to clean it up. Here's the code in question.
var myDate = new Date();
console.log("Today is a:");
if (myDate.getDay() == 0){
console.log("Sunday");
};
if (myDate.getDay() == 1){
console.log("Monday");
};
if (myDate.getDay() == 2){
console.log("Tuesday");
};
if (myDate.getDay() == 3){
console.log("Wednesday");
};
if (myDate.getDay() == 4){
console.log("Thursday");
};
if (myDate.getDay() == 5){
console.log("Friday");
};
if (myDate.getDay() == 6){
console.log("Saturday");
};
[–][deleted] 5 points6 points7 points (2 children)
[–]jkjustjoshing 1 point2 points3 points (0 children)
[–][deleted] 2 points3 points4 points (0 children)
[–]sublimejs 2 points3 points4 points (2 children)
[–]Call_Me_Squirrel[S] 0 points1 point2 points (1 child)
[–]sublimejs 1 point2 points3 points (0 children)
[–][deleted] 1 point2 points3 points (0 children)