Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const artists = ['Picasso', 'Kahlo', 'Matisse', 'Utamaro'];
- //Performs the specified action for each element in an array.
- artists.forEach(artist => {
- console.log(artist + ' is one of my favorite artists.');
- });
- const numbers = [1, 2, 3, 4, 5];
- //Calls a defined callback function on each element of an array, and returns an array that contains the results.
- const squareNumbers = numbers.map(number => {
- return number * number;
- });
- console.log(squareNumbers);
- const things = ['desk', 'chair', 5, 'backpack', 3.14, 100];
- const onlyNumbers = things.filter(thing => {
- return typeof thing === 'number';
- });
- console.log(onlyNumbers);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement