Day 21 of Scrimba JavaScriptmas — Valid Time

  • const str = ‘13:58’;
  • const str = ‘25:51’;
  • const str = ‘02:76’;
if (0 <= str2[0] <= 24 && 0 <= str2[1] <= 60)
if(str2[0]<=24 && str2[1]<=60)
function validTime(str) {
// write code here.
let str2 = str.split(':')
let valid = true

for(i=0;i<str2.length;i++){
if(str2[0]<=24 && str2[1]<=60){
return valid
}else{
return !valid
}
}
}

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store