Use number format browser API

This commit is contained in:
Marcel Schwarz 2023-04-12 12:41:25 +02:00
parent 3d92aaf8c4
commit 54b316d7b2

View File

@ -39,7 +39,7 @@ function updateLayout() {
currentCpu = getRandomCpu(); currentCpu = getRandomCpu();
document.getElementById("currentCpuTitle").innerText = currentCpu.name; document.getElementById("currentCpuTitle").innerText = currentCpu.name;
// add "." to large numbers // add "." to large numbers
document.getElementById("currentCpuScore").innerText = currentCpu.score.toString().length > 3 ? currentCpu.score.toString().slice(0, currentCpu.score.toString().length - 3) + "." + currentCpu.score.toString().slice(currentCpu.score.toString().length - 3) : currentCpu.score; document.getElementById("currentCpuScore").innerText = new Intl.NumberFormat().format(currentCpu.score)
nextCpu = getRandomCpu(); nextCpu = getRandomCpu();
document.getElementById("nextCpuTitle").innerText = nextCpu.name; document.getElementById("nextCpuTitle").innerText = nextCpu.name;
} }