let hour = Number(prompt("Enter the hour: ")) let minutes = Number(prompt("Enter the minutes: ")) let seconds = Number(prompt("Enter the seconds: ")) if ( hour >= 0 && hour <= 23 && minutes >= 0 && minutes <= 59 && seconds >=0 && seconds <= 59 ){ seconds++ if (seconds === 60){ seconds = 0; minutes++ if (minutes === 60){ minutes = 0; hour++ if (hour === 24){ hour = 0; } } } console.log (`In a second the time will be ${hour}: ${minutes} : ${seconds}`); } else { console.log("Enter correct information"); }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter