Numbers have many ways to be displayed on the screen, one of that is to show them in short or compact ways. Instead of an enormous number like 123456
, show 123K
. This and other summarized forms can be easily done by using Intl.NumberFormat
Instructor: [0:01] Another number formatting option is to display the number in a compact or short format. This can be done by using the options provided by the number format API. [0:15] Let's create a formatter function and return a new number format object with the option notation as compact. Let's call the formatter a few times with different numbers and console.log this.
[0:35] You can see in the console that the numbers are shown in a compact or summarized way. You can notice that there are many, many options that can help you define what format you want to use for your numbers.
[0:51] Another option for the notation property is to use scientific as a value. This will change the displayed value as scientific numbers.
[1:04] In summary, the number format object provided by the Intl API allows you to change the way numbers are represented in the screen by using the many options provided by the API.
Member comments are a way for members to communicate, interact, and ask questions about a lesson.
The instructor or someone from the community might respond to your question Here are a few basic guidelines to commenting on egghead.io
Be on-Topic
Comments are for discussing a lesson. If you're having a general issue with the website functionality, please contact us at support@egghead.io.
Avoid meta-discussion
Code Problems?
Should be accompanied by code! Codesandbox or Stackblitz provide a way to share code and discuss it in context
Details and Context
Vague question? Vague answer. Any details and context you can provide will lure more interesting answers!