Pen Settings

HTML

CSS

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. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

JavaScript

Babel is required to process package imports. If you need a different preprocessor remove all packages first.

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

Behavior

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.

HTML

              
                
              
            
!

CSS

              
                
              
            
!

JS

              
                // This can be brought into a simple one liner like this:
// return (typeof value === 'number') && value === Number(value) && Number.isFinite(value)

// We'll just use guard clauses here.
function isNumber (value) {
  // We will not coerce boolean to numbers, although we could.
  // We will not coerce strings to numbers, even though we could try.
  // Referencing https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/typeof
  if (typeof value !== 'number') {
    return false
  }

  // Consider this as the NaN check.
  // NaN is a number.
  // NaN has the unique property of never equaling itself.
  // Pulled this hack right off of MDN: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/isNaN
  if (value !== Number(value)) {
    return false
  }
  
  // At this point, we for sure have some sort of number.
  // But not all numbers are finite, and realistically we want finite numbers.
  if (Number.isFinite(value) === false) {
    return false
  }

  return true
}

// Debugging code.
// Let's attempt some quirky stuff and mess with the full list of data types.
// These should all fail:
console.assert(isNumber(true) === false, 'A Boolean is not a Number!')
console.assert(isNumber('true') === false, 'A String is not a Number!')
console.assert(isNumber('1') === false, 'A String is not a Number!')
console.assert(isNumber('1.2') === false, 'A String is not a Number!')
console.assert(isNumber(NaN) === false, 'NaN is evil, and not a Number!')
console.assert(isNumber([]) === false, 'An Object is not a Number!')
console.assert(isNumber({}) === false, 'An Object is not a Number!')
console.assert(isNumber(null) === false, 'An Object is not a Number!')
console.assert(isNumber(undefined) === false, 'Undefined is not a Number!')
console.assert(isNumber(function () {}) === false, 'A Function is not a Number!')
console.assert(isNumber(Symbol('no one uses these... ever')) === false, 'A Function is not a Number!')
console.assert(isNumber('') === false, 'A String is not a Number!')
console.assert(isNumber('   ') === false, 'A String is not a Number!')
console.assert(isNumber('-1.1') === false, 'Strings are not numbers.')
console.assert(isNumber('0') === false, 'Strings are not numbers.')
console.assert(isNumber('012') === false, 'Strings are not numbers.')
console.assert(isNumber('0xff') === false, 'Strings are not numbers.')
console.assert(isNumber('1') === false, 'Strings are not numbers.')
console.assert(isNumber('1.1') === false, 'Strings are not numbers.')
console.assert(isNumber('10') === false, 'Strings are not numbers.')
console.assert(isNumber('10.10') === false, 'Strings are not numbers.')
console.assert(isNumber('100') === false, 'Strings are not numbers.')
console.assert(isNumber('5e3') === false, 'Strings are not numbers.')
console.assert(isNumber(Infinity) === false, 'Infinity is not REALLY a number.')

// These should pass:
console.assert(isNumber(1) === true, 'An Integer, is totally a Number!')
console.assert(isNumber(1.2) === true, 'A Float, is totally a Number!')
console.assert(isNumber(-1) === true, 'An Integer, is totally a Number!')
console.assert(isNumber(-1.2) === true, 'A Float, is totally a Number!')
console.assert(isNumber(0) === true, 'A Float, is totally a Number!')
console.assert(isNumber(Math.abs(100)) === true, 'A Float even from a Function, is totally a Number!')
console.assert(isNumber(5e3) === true, 'Scientific notation should come back as a number.')
console.assert(isNumber(0xff) === true, 'Hex literals should come  back as a number.')
console.assert(isNumber(-1.1) === true, 'Negative decimals should come back as a number.')
console.assert(isNumber(0) === true, 'Zero should come back as a number.')
console.assert(isNumber(1) === true, 'Whole numbers should come back as a number, even 1.')
console.assert(isNumber(1.1) === true, 'Positive decimals should come back as a number.')
console.assert(isNumber(10) === true, 'Whole numbers should come back as a number.')
console.assert(isNumber(10.10) === true, 'Whole numbers should come back as a number.')
console.assert(isNumber(100) === true, 'Whole numbers should come back as a number.')
console.assert(isNumber(parseInt('012')) === true, 'A string parsed into a number should come back as a number.')
console.assert(isNumber(parseFloat('012')) === true, 'A string parsed into a number should come back as a number.')
console.assert(isNumber(Math.PI) === true, 'PI is a number.')
              
            
!
999px

Console