How to display the current day in TypeScript

1 Answer

0 votes
const today : Date = new Date();
const day : number = today.getDay();
const days : string[] = ["Sunday","Monday","Tuesday","Wednesday ","Thursday","Friday","Saturday"];

console.log("Today is: " + days[day]);




/*
run:

"Today is: Monday"

*/

 



answered Nov 7, 2022 by avibootz
edited Nov 7, 2022 by avibootz

Related questions

1 answer 127 views
1 answer 148 views
1 answer 94 views
1 answer 128 views
1 answer 177 views
1 answer 122 views
1 answer 118 views
...