Public
Edited
Oct 24, 2023
Insert cell
Insert cell
function quantityFormat(num) {
return '' + num.toFixed(2).replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1,');
}
Insert cell
quantityFormat(17000000000);
Insert cell
function arrayQuantityFormat(array) {
function quantityFormat(num) {
return '' + num.toFixed(2).replace(/(\d)(?=(\d{3})+(?!\d))/g, '$1,');
}
let arrayNumbers = array.map(Number);
let result = arrayNumbers.map(quantityFormat);
return result;
}
Insert cell
list = ["17000000000","2","3"]
Insert cell
arrayQuantityFormat(list)
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more