How to change the time depending on value in javascript if it has colon, remove the colon and should be integer format if it has no colon, add the colon in javascript
function checkColon(str) {
return str.replace(/:/g, '');
}
var t1 = "10:40"
var t2 = "01:40"
var t3 = "0240"
var t4 = "1250"
console.log(this.checkColon(t1), this.checkColon(t2), this.checkColon(t3), this.checkColon(t4));
Expected Output:
1040
0140
02:40
12:50
"