kimpro82 / MyPractice

Born in October and learn like octopus
0 stars 0 forks source link

TypeScript : Big Block Lettering in Console #267

Closed kimpro82 closed 1 year ago

kimpro82 commented 1 year ago

Run

tsc TsBigBlockLettering.ts
node TsBigBlockLettering.js

Results

알파벳 문자열을 입력하세요: uebermensch
#.....#.#######.######..#######.######..#.....#.#######.#.....#..#####..#######.#.....#.
#.....#.#.......#.....#.#.......#.....#.##...##.#.......##....#.#.......#.......#.....#.
#.....#.#.......#.....#.#.......#.....#.#.#.#.#.#.......#.#...#.#.......#.......#.....#.
#.....#.######..######..######..######..#..#..#.######..#..#..#..#####..#.......#######.
#.....#.#.......#.....#.#.......#.....#.#.....#.#.......#...#.#.......#.#.......#.....#.
#.....#.#.......#.....#.#.......#.....#.#.....#.#.......#....##.......#.#.......#.....#.
#######.#######.######..#######.#.....#.#.....#.#######.#.....#..#####..#######.#.....#.
kimpro82 commented 1 year ago

Future Improvements

kimpro82 commented 1 year ago

by ChatGPT

Q. 이 함수가 직접 'print'라는 행위를 하지 않으니 더 적합한 함수명과 주석으로 고쳐줘.

    // 알파벳 문자열 출력 함수
    function printAlphabetString(alphabet: string) {
        const alphabetDataString = alphabetData[alphabet];
        for (let i = 0; i < alphabetDataString.length; i++) {
            const char = alphabetDataString[i];
            if (outputArray[i]) {
                outputArray[i] += char;
            } else {
                outputArray[i] = char;
            }
        }
    }

A.

    // 알파벳 문자열을 출력용 배열에 누적하는 함수
    function accumulateAlphabetString(alphabet: string) {
        const alphabetDataString = alphabetData[alphabet];
        for (let i = 0; i < alphabetDataString.length; i++) {
            const char = alphabetDataString[i];
            if (outputArray[i]) {
                outputArray[i] += char;
            } else {
                outputArray[i] = char;
            }
        }
    }

해당 함수는 알파벳 문자열을 출력용 배열에 누적하여 저장하는 역할을 합니다. 함수명과 주석을 이에 맞게 수정하였습니다.

kimpro82 commented 1 year ago

gogo