cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - ActiveLovehtmlicon-new-collectionicon-personicon-teamlog-outoctocatpop-outspinnerstartv

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.

Quick-add: + add another resource

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.

Quick-add: + add another resource

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.

            
              // Read full post at: https://jchiatt.com/worklog-062018-new-javascript-array-methods

// Data for methods below:
const people = ["Bob", "Alice", "Joe", "Jack", "Maria"];

/* 
.some() tests whether at least one element in the array passes the test you provide as a callback function.

Note that it immediately returns as soon as it finds the first true value, so it has no idea if there are multiple elements within the array that would pass true. It only cares that there's at least one.
*/

const startsWithJ = function(element) {
  // checks whether an element starts with the letter "J"
  return element[0] === "J";
};

console.log(people.some(startsWithJ));
// expected output: true

/*
.includes() checks whether the array includes a specific value you pass in, returning true or false.
*/

console.log(people.includes("Alice"))
// expected output: true


/*
.from() creates a new array from an array-like or iterable object. Note that it only creates a shallow copy, so nested values aren't copied. You can also pass in an optional map function to call on every element of the array as it is added.
*/

console.log(Array.from(people, person => person + " Smith"))
// expected output: ["Bob Smith", "Alice Smith", "Joe Smith", "Jack Smith", "Maria Smith"]
            
          
!
999px
Loading ..................

Console