const inputDate = '1/1/22';
let arr = inputDate.split('/'); //splits the date where it finds /
console.log('Splitting date:', arr);
let dayEdited = false;
let monthEdited = false;
let yearEdited = false;
if (arr[0] < 10) {
arr[0] = "0" + arr[0];
console.log('add zero to month:', arr[0]);
dayEdited = true;
}
if (arr[1] < 10) {
arr[1] = "0" + arr[1];
console.log('add zero to day:', arr[1]);
monthEdited = true;
}
if (arr[2] < 2000) {
arr[2] = "20" + arr[2];
console.log('add 20 to Year:', arr[2]);
yearEdited = true;
}
if (yearEdited && monthEdited && dayEdited) {
let longerDate = arr[2] + arr[0] + arr[1] + "000000"; //rearranges the array by YEAR, MONTH, DAY
console.log('Longer Date:', longerDate);
} else if (!yearEdited && monthEdited && dayEdited) {
let longerDate = arr[2] + arr[0] + arr[1] + "000000"; //rearranges the array by YEAR, MONTH, DAY
console.log('Longer Date :', longerDate);
} else if (!yearEdited && !monthEdited && dayEdited) {
let longerDate = arr[2] + arr[0] + arr[1] + "000000"; //rearranges the array by YEAR, MONTH, DAY
console.log('Longer Date:', longerDate);
} else if (!yearEdited && monthEdited && !dayEdited) {
let longerDate = arr[2] + arr[0] + arr[1] + "000000"; //rearranges the array by YEAR, MONTH, DAY
console.log('Longer Date:', longerDate);
} else if (yearEdited && !monthEdited && !dayEdited) {
let longerDate = arr[2] + arr[0] + arr[1] + "000000"; //rearranges the array by YEAR, MONTH, DAY
console.log('Longer Date:', longerDate);
} else if (!yearEdited && !monthEdited && !dayEdited) {
let longerDate = arr[2] + arr[0] + arr[1] + "000000"; //rearranges the array by YEAR, MONTH, DAY
console.log('Longer Date:', longerDate);
}