print numbers with commas as thousand separators in JavaScript
![](https://cdn-icons-png.flaticon.com/512/5968/5968292.png)
JavaScript
🤖 Code Explanation
The code defines a function to add commas to a number. The function takes a number as a parameter and returns a string with commas in the appropriate places. For example, the number 1000000 would be returned as "1,000,000".
![](https://cdn-icons-png.flaticon.com/512/5968/5968292.png)
More problems solved in JavaScript
![](https://cdn-icons-png.flaticon.com/512/5968/5968292.png)
![](https://cdn-icons-png.flaticon.com/512/5968/5968292.png)
![](https://cdn-icons-png.flaticon.com/512/5968/5968292.png)
![](https://cdn-icons-png.flaticon.com/512/5968/5968292.png)
![](https://cdn-icons-png.flaticon.com/512/5968/5968292.png)
![](https://cdn-icons-png.flaticon.com/512/5968/5968292.png)
![](https://cdn-icons-png.flaticon.com/512/5968/5968292.png)
![](https://cdn-icons-png.flaticon.com/512/5968/5968292.png)
![](https://cdn-icons-png.flaticon.com/512/5968/5968292.png)
![](https://cdn-icons-png.flaticon.com/512/5968/5968292.png)
![](https://cdn-icons-png.flaticon.com/512/5968/5968292.png)
![](https://cdn-icons-png.flaticon.com/512/5968/5968292.png)
![](https://cdn-icons-png.flaticon.com/512/5968/5968292.png)
![](https://cdn-icons-png.flaticon.com/512/5968/5968292.png)
![](https://cdn-icons-png.flaticon.com/512/5968/5968292.png)
![](https://cdn-icons-png.flaticon.com/512/5968/5968292.png)
![](https://cdn-icons-png.flaticon.com/512/5968/5968292.png)
![](https://cdn-icons-png.flaticon.com/512/5968/5968292.png)
![](https://cdn-icons-png.flaticon.com/512/5968/5968292.png)
![](https://cdn-icons-png.flaticon.com/512/5968/5968292.png)
![](https://cdn-icons-png.flaticon.com/512/5968/5968292.png)