in Education by
My node 8 function, hosted at Firebase Cloud Functions isn't working as expected. I've a toLocaleString call passing all parameters to format in Brazilian currency format, but I getting the default EN format. The function: const value = 10825.20645 const formatted = value.toLocaleString('pt-br', { style: 'currency', currency: 'BRL', decimals: 2 }) Expected result R$ 10.825,21 Actual result at CloudFunction R$ 10,825.21 Running the same function on browser is working fine const value = 10825.20645 const formatted = value.toLocaleString('pt-br', { style: 'currency', currency: 'BRL', decimals: 2 }) console.log(formatted) // R$ 10.825,21 Run code snippetExpand snippet JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
To solve this (in part, I'll explain), I used INTL API as suggested by @hybrdthry911. By default, nodejs only load the EN lang. const intl = require('intl') const locale = intl.NumberFormat('pt-br', { style: 'currency', currency: 'BRL', decimals: 2 }) const value = 10825.20645 const formatted = locale.format(value) console.log(formatted) // R$10.825,21 But, it still different from my expected result. In browsers, I get an space after the currency symbol, but with INTL. Expected: R$ 10.825,21 Result: R$10.825,21 It's a small problem, I'll do a search about.

Related questions

0 votes
    My node 8 function, hosted at Firebase Cloud Functions isn't working as expected. I've a toLocaleString ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 7, 2022 in Education by JackTerrance
0 votes
    I am getting the error 'Uncaught TypeError: firebase.auth is not a function'. My code was working perfectly ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 14, 2022 in Education by JackTerrance
0 votes
    The basic purpose of the toLocaleString() is to _________ (1)return a localised object representation (2)return a ... (4)return a localized string representation of the object...
asked May 18, 2021 in Technology by JackTerrance
0 votes
    My code: PhoneAuthProvider.getInstance().verifyPhoneNumber( phoneNumber, // Phone number to verify 60, // Timeout ... for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 20, 2022 in Education by JackTerrance
0 votes
    Error: Type com.google.android.gms.common.internal.zzf is referenced as an interface from `com.google. ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 14, 2022 in Education by JackTerrance
0 votes
    I'm trying to use the mail() function on my computer so I can test the web application's system ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 30, 2022 in Education by JackTerrance
0 votes
    Can any body help me find out, why this link(webRTC example) http://goo.gl/PNMSII not working on ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 26, 2022 in Education by JackTerrance
0 votes
    Can any body help me find out, why this link(webRTC example) http://goo.gl/PNMSII not working on ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 20, 2022 in Education by JackTerrance
0 votes
    I am trying to write some stuff in a file using reactJS and nodeJs but it doesnt work. Here is ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 7, 2022 in Education by JackTerrance
0 votes
    Course Results (${courseResponseList.getCourses().size()}) Want to show above div. jquery script. jQuery. ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 6, 2022 in Education by JackTerrance
0 votes
    I am trying to write some stuff in a file using reactJS and nodeJs but it doesnt work. Here is ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 26, 2022 in Education by JackTerrance
0 votes
    Course Results (${courseResponseList.getCourses().size()}) Want to show above div. jquery script. jQuery. ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 20, 2022 in Education by JackTerrance
0 votes
    I have a dataset with employee payroll information (df2). It has a date, job title, shift start ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 12, 2022 in Education by JackTerrance
0 votes
    I have a web application that uses the current version of JQuery that needs to get some JSON objects back ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 11, 2022 in Education by JackTerrance
0 votes
    I have created a plugin and used a reference to another project (DLL) I have created. The problem ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Feb 27, 2022 in Education by JackTerrance
...