css Audio - Active file-generic CSS - Active Generic - Active HTML - Active JS - Active SVG - Active Text - Active file-generic Video - Active header Love html icon-new-collection icon-person icon-team numbered-list123 pop-out spinner split-screen star tv

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. 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

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

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

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation


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.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

              <p>You will need to open the console view to see the console.logs</p>
              // arguments object - no longer bound with arrow functions
// ES 5

// const add = function (a,b) {
//    console.log(arguments)
//    return a + b
// }
// console.log(add(55,1))

// AS ES6
const add = (a, b) => {
  // console.log(arguments)
  return a + b
// so if for some odd reason you need to access the arguments
// you will need to use ES5 and not ES6 or 7
console.log(add(55, 1))

// ---------------
// this keyword - nolonger bound 

// ES 5

const user1 = {
  name1: 'Richard',
  cities1: ['Weymouth', 'Phoenix', 'San Francisco', 'Bournemouth'],
  printPlacesLived1: function () {
    const that = this

    this.cities1.forEach(function (city1) {
      console.log(that.name1 + ' has lived in ' + city1)
    console.log('END OF LIST')
// in order to make the above work, we need to use a 'work-around' by adding a new variable to hold
// the this to that because the function is bound to the property because the 2nd function
// is nested the this will not work as it is bound to the first function method - 
// hence the this = that to bring down the that. That is ES 5 for you! in ES 6 below - 
// the value is not bound.

const user = {
  name: 'Richard',
  cities: ['Weymouth', 'Phoenix', 'San Francisco', 'Bournemouth'],
  printPlacesLived() {
    return this.cities.map((city) => this.name + ' has lived in ' + city)

// so... like var - we tend to never need the function keyword any more in ES 6
// arrow functions are the way forward! You can still use function, but arrows are
// just cleaner and work better
// the above app was very much like the ES 5 version, but I then took out 'forEach'
// and replaced it with .map as this works better in ES 6
// the map returns new arrays on the array so you can do things with what is returned 
// in the map that you cannot with the forEach

// ------------------------

// Challenge area

const multiplier = {
  // [numbers]
  numbers: [5345, 74754, 67568768],
  multiplyBy: 5475643,
  multiply() {
      return this.numbers.map((number) => number * this.multiplyBy);
  // multiply by a single number
  // multiply  - return a new array were the numbers have been multiplied (map)

// so [1, 2, 3] 2 = [2, 4 , 6]

// so we get an array of numbers and a number toi multiplyBy
// we then set a function - multiply to return this number array and
// map it to a new array = number. Then we take the new array and
// multiply it by the number stored in multiplyBy
// then we set up a console.log to run the function in the multiplier const

🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.
Loading ..................