Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ add another resource


Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource


Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.


Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.


                <div ng-app="app" ng-controller="appCtrl">
  <span class="jumbotron title">

    <span ng-repeat="number in numbers">
      <b  class="badge badge-primary bigger" > 
        {{number.value | formatNumber: number.format}}



                body {
  text-align: center;
.title {
  background-color: #cccfff;
  display: block;
  color: rgb(0, 100, 255);

.bigger {
  font-size: 2em;
  display: inline-block;
  margin: .1em;


                angular.module('app', [])
  .config(() => {})
  .run(() => {})

  .controller('appCtrl', appCtrl)

  .filter('formatNumber', formatNumber)

// number filter/pipe based on d3.format()
// a few examples
// d3.format(".0%")(0.123);  // rounded percentage, "12%"
// d3.format("($.2f")(-3.5); // localized fixed-point currency, "(£3.50)"
// d3.format("+20")(42);     // space-filled and signed, "                 +42"
// d3.format(".^20")(42);    // dot-filled and centered, ".........42........."
// d3.format(".2s")(42e6);   // SI-prefix with two significant digits, "42M"
// d3.format("#x")(48879);   // prefixed lowercase hexadecimal, "0xbeef"
// d3.format(",.2r")(4223);  // grouped thousands with two significant digits, "4,200"
class Format {
  constructor () {}
  number (n, f) {
    const format = f || '1.0?s'
    let number
    // Put business logic here
    switch (format) {
      case '$1.00':
        number = d3.format('$.2s')(n)
      case '$1,000.00':
        number = d3.format('$,2f')(n)
      case '1.0?s':
        if (/\.0/.test(d3.format('.2s')(n))) {
          number = d3.format('~s')(n)
        } else {
          number = d3.format('.2s')(n)
        number = d3.format(format)(n)
    console.log('run', [n, number])
    return number.replace(/G/, "B").toUpperCase()

function formatNumber () {
  return new Format().number

appCtrl.$inject = ['$scope']
function appCtrl ($scope) {
  $scope.title = 'Fun with numbers 🇺🇸'
  const thousand = 1500
  const thousands = 2333
  const million = 1000000
  const millpoint5 = 1555000
  const billion = 10000000000
  const trillion = 1000000000000
  const BigMoney = 15000000.99
  const money = 1000.23
  $scope.numbers = [
    {value: thousand},
    {value: thousands},
    {value: million},
    {value: millpoint5},
    {value: billion},
    {value: BigMoney, format: '$1.00'},
    {value: money, format: '$,'},
    {value: trillion}