koreanSubjectParticleModifyer

// Some code

```typescript

export function koreanSubjectParticleModifyer(korean: string): string {
  // name의 마지막 음절의 유니코드(UTF-16)
  const charCode = korean.charCodeAt(korean.length - 1);

  // 유니코드의 한글 범위 내에서 해당 코드의 받침 확인
  const consonantCode = (charCode - 44032) % 28;

  let particle: string;

  if (consonantCode === 0) {
    // 0이면 받침 없음 -> 가
    particle = "가";
  } else {
    // 1이상이면 받침 있음 -> 이
    particle = "이";
  }

  // 결과값으로 한국어의 조사에 '가/이'가 붙어서 출력
  const result = `${korean}${particle}`;

  // 예상과 다를 경우 에러를 출력
  console.assert(result === koreanSubjectParticleModifyer(korean), `결과 실패: 한국어(${korean}) 가 입력되어 예상치 못한 결과가 발생했습니다.`);

  return result;
}

```

Last updated