If you want to display the current time using JavaScript, you can utilize the built-in methods of the Date
object:
let currentDate = new Date();
let minutes = currentDate.getMinutes();
let seconds = currentDate.getSeconds();
console.log(minutes + ':' + seconds);
To ensure that the output is easily readable, you can add a leading zero to the minutes and seconds if they are less than 10:
let currentDate = new Date();
let minutes = currentDate.getMinutes();
let seconds = currentDate.getSeconds();
minutes = minutes < 10 ? ('0' + minutes) : minutes;
seconds = seconds < 10 ? ('0' + seconds) : seconds;
console.log(minutes + ':' + seconds);