I'm getting out put as 'Undefined' for following code. Can anyone correct me please?

let text;
function day(){
switch (new Date().getDay()) {
case 6:
text = “Today is Saturday”;
break;
case 0:
text = “Today is Sunday”;
break;
default:
text = “Looking forward to the Weekend”;

}
}
console.log(day());

Please Tell us what’s happening in your own words.

Learning to describe problems is hard, but it is an important part of learning how to code.

Also, the more you say, the more we can help!

A function that doesn’t have a return statement will return undefined.

Got the fault with lot of thanx :blush: :blush:

1 Like