I have below javascript funtionthis JavaScript function which checks if the format has 'yyyy' and replaces 'yy' with 'y'
below is my function:
function validateDateFormat(format) {
if(format.indexOf("yyyy") != -1)
return format.replace(/yy/g, 'y');
else return format;
}
I feel like it can be simplified further, can. Can someone help me to refactor/optimize it?