문제 링크 : Latest Time You Can Obtain After Replacing Characters
/**
* @param {string} s
* @return {string}
*/
var findLatestTime = function(s) {
let result = ''
for(let i in s) {
if(s[i] === '?') {
if(i == 0) {
if(s[1] === '?' || s[1] < '2') {
result += '1'
} else {
result += '0'
}
} else if(i == 1) {
if(s[0] === '1') {
result += '1'
}else if(s[0] === '?') {
result += '1'
}else {
result += '9'
}
} else if( i == 3) {
result += '5'
} else {
result += '9'
}
} else {
result += s[i]
}
}
return result
};