Tag: Memformat
Program JavaScript untuk Memformat Tanggal
Contoh 1: Format Tanggal // program to format the date // get current date let currentDate = new Date(); // get the day from the date let day = currentDate.getDate(); // get the month from the date // + 1 because month starts from 0 let month = currentDate.getMonth() + 1; // get the year […]
Read more »Program JavaScript untuk Memformat Angka sebagai String Mata Uang
Contoh 1: Memformat Angka sebagai String Mata Uang // program to format numbers as currency string const formatter = new Intl.NumberFormat(‘en-US’, { style: ‘currency’, currency: ‘USD’ }); formatter.format(2500); Keluaran $2,500.00 Dalam program di atas, kami telah menggunakan Intl.NumberFormat obyek. Itu Intl.NumberFormat objek memungkinkan pemformatan angka peka bahasa. Contoh 2: Memformat Angka sebagai String Mata Uang […]
Read more »