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 143 views
1 answer 160 views
1 answer 109 views
1 answer 141 views
1 answer 189 views
1 answer 138 views
1 answer 133 views
...