3

I want to make a function to add 2 currency with string format and dynamic by language code. something like this

function addCurrecy(c1, c2, lang) {
  /* */
  return c
}

console.log(addCurrecy('3.319,00 €', '100,00 €', 'de-DE')) // '3.419,00 €'
console.log(addCurrecy('CHF 1’719.90', 'CHF 100.00', 'de-CH')) // 'CHF 1’819.90'

The Intl.NumberFormat() can help me format the number, but I get stuck at plus number. Any suggestion guys?

bird
  • 1,872
  • 1
  • 15
  • 32
  • 2
    @jsN00b it is ISO Language Code and used as param in `Intl.NumberFormat()`. You can check list of lang here http://www.lingoes.net/en/translator/langcode.htm – bird Mar 27 '22 at 05:11
  • What is needed here is a way to reverse the Intl.NumberFormat in order to obtain the actual numbers, then perform the addition and again use Intl.NumberFormat to reformat it to currency. There are other answers that help with this. Please check [this](https://stackoverflow.com/q/55364947/13658816), and [may be this too](https://stackoverflow.com/q/29255843/13658816). – jsN00b Mar 27 '22 at 05:12

0 Answers0