주어진_문자열.padStart(지정한_길이[, 채우길_원하는_문자열]);
const str = "hello"; // 주어진 문자열(문자열의 길이: 5)

// 주어진_문자열.padStart(지정한_길이[, 채우길_원하는_문자열]);
// 지정한 길이: 10, 채우길 원하는 문자열: "*"
const resultStr = str.padStart(10, "*");

console.log(resultStr); // 출력: "*****hello"
str.padStart(targetLength)
str.padStart(targetLength, padString)
const str = "hello"; // 주어진 문자열(문자열의 길이: 5)

// 지정한 길이: 10, 채우길 원하는 문자열: "*@"
const resultStr = str.padStart(10, "*@");

console.log(resultStr); // 출력: "*@*@*hello"
const str = "hello"; // 주어진 문자열(문자열의 길이: 5)

// 지정한 길이: 10, 채우길 원하는 문자열을 지정하지 않음
const resultStr = str.padStart(10);

// 빈 공백이 채워짐
console.log(resultStr); // 출력: "     hello"
// 현재 시각 가져오기
const now = new Date();

const hours = now.getHours();    // 0 ~ 23
const minutes = now.getMinutes(); // 0 ~ 59
const seconds = now.getSeconds(); // 0 ~ 59

// padStart로 항상 두 자리 숫자로 포맷
const formattedHours = String(hours).padStart(2, "0");
const formattedMinutes = String(minutes).padStart(2, "0");
const formattedSeconds = String(seconds).padStart(2, "0");

// 시:분:초 형태로 출력
const currentTime = `${formattedHours}:${formattedMinutes}:${formattedSeconds}`;

console.log(currentTime); // 예: "03:07:05"
// 전송해야 하는 고정 길이 코드
const code1 = "A7";
const code2 = "B12";

// padStart로 앞쪽을 0으로 채워 고정 길이 6으로 맞춤
const fixedCode1 = code1.padStart(6, "0");
const fixedCode2 = code2.padStart(6, "0");

console.log(fixedCode1); // 출력: "0000A7"
console.log(fixedCode2); // 출력: "000B12"