Skip to content

Instantly share code, notes, and snippets.

@yamoo9
Created January 7, 2026 17:41
Show Gist options
  • Select an option

  • Save yamoo9/fd2b510f86eff14b5540afd56282553b to your computer and use it in GitHub Desktop.

Select an option

Save yamoo9/fd2b510f86eff14b5540afd56282553b to your computer and use it in GitHub Desktop.
달러(usd) → 한국 원화로 환산한 금액(정수)을 반환하는 함수
function convertUsdToKrw(usd, exchangeRate) {
// 데이터 정제 (문자열에서 숫자만 추출)
const numberUsd = parseFloat(usd)
const numberRate = parseFloat(exchangeRate)
// 계산 (달러 * 환율)
const calcValue = numberUsd * numberRate
// 데이터 가공 (소수점 제거 및 정수화)
const result = parseInt(calcValue, 10)
// 최종 결과 반환 (단위 결합)
return result + '원'
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment