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

              
                <body>
  <h1>JavaScript30 - Day06 - Array Cardio Day 2</h1>
  <p>Have a look in the Console for the results of these Array Methods:</p>
  <ol>
    <li><code>Array.prototype.some()</code> - Is at least one person 19 or older?</li>
    <li><code>Array.prototype.every()</code> - Is everyone 19 or older?</li>
    <li><code>Array.prototype.find()</code> - Find the comment with the ID of 823423</li>
    <li><code>Array.prototype.findIndex()</code> - Find the comment with this ID</li>
    <li><code>Array.prototype.splice()</code> / <code>Array.prototype.slice()</code> - delete the comment with the ID of 823423</li>
  </ol>
</body>
              
            
!

CSS

              
                body {
  margin: 0 auto;
  max-width: 680px;
  padding-left: 10px;
  padding-right: 10px;
}
              
            
!

JS

              
                 const people = [
  { name: 'Wes', year: 1988 },
  { name: 'Kait', year: 1986 },
  { name: 'Irv', year: 1970 },
  { name: 'Lux', year: 2015 }
];

 const comments = [
  { text: 'Love this!', id: 523423 },
  { text: 'Super good', id: 823423 },
  { text: 'You are the best', id: 2039842 },
  { text: 'Ramen is my fav food ever', id: 123523 },
  { text: 'Nice Nice Nice!', id: 542328 }
];

// Some and Every Checks
// Array.prototype.some() // is at least one person 19 or older?
const isAdult = people.some(person => ((new Date()).getFullYear()) - person.year >= 19);
console.log({isAdult});

// Array.prototype.every() // is everyone 19 or older?
const allAdult = people.every(person => ((new Date()).getFullYear()) - person.year >= 19);
console.log({allAdult});

// Array.prototype.find()
// Find is like filter, but instead returns just the one you are looking for
// find the comment with the ID of 823423
const comment = comments.find( comment => comment.id === 823423);
console.log(comment);

// Array.prototype.findIndex()
// Find the comment with this ID
// delete the comment with the ID of 823423
const index = comments.findIndex( comment => comment.id === 823423);

comments.splice(index, 1);

const newComments = [
  ...comments.slice(0, index),
  ...comments.slice(index)
]
console.log(index);
              
            
!
999px

Console