I'm trying to make a calculator in JavaScript. I'd like to add a comma separator to the whole number when it displayed to input. I want to do it by using toLocaleString method but it doesn't work.
function addComma() {
const display = document.querySelector('.display');
let disVal = display.value;
if (disVal !== '') {
return display.value = Number(disVal).toLocaleString();
}
}