Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const boxes = document.querySelectorAll('.box');
- // ES5
- //var boxesArr5 = Array.prototype.slice.call(boxes);
- //boxesArr5.forEach(function(cur) { cur.style.backgroundColor = 'dodgerblue'});
- // ES6
- Array.from(boxes).forEach(cur => cur.style.backgroundColor = 'dodgerblue');
- // Loops in ES6
- for (const cur of boxes) {
- if (cur.className.includes('blue')) {
- continue;
- }
- cur.textContent = 'I changed to blue!';
- }
- // ES 5
- var ages = [12, 17, 8, 21, 14, 11]
- var full = ages.map(function(cur) {
- return cur >= 18;
- });
- console.log(ages);
- //A lof of work to get a true or false for ages
- console.log(full.indexOf(true));
- console.log(ages[full.indexOf(true)]);
- // ES 6
- // of all the ages, find the index location where cur >= 18
- console.log(ages.findIndex(cur => cur >= 18));
- console.log(ages.find(cur => cur >= 18));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement