Search
Close this search box.
Search
Close this search box.
Search
Close this search box.

How to dump the for loop and stay alive

Facebook
Twitter
LinkedIn
Pinterest
WhatsApp
var arr  ['a', 'b', 'c', 'd', 'e'];
for (var i  0; i < arr.length; i++) {
  console.log(arr[i]);
}

The example array

var people  [{
  id: 1,  
  name: 'Alice',
  age: 16
},
{
  id: 2,
  name: 'Bob',
  age: 19
},
{
  id: 3,
  name: 'Carol',
  age: 15
},
{
  id: 4,
  name: 'David',
  age: 21
}];

Sum an array

var sum  0;for (var i  0; i < people.length; i++) {
  sum += people[i].age;
}
const sum  people.reduce(function(acc, person){
  return acc + person.age;
}, 0)
const sum  people.reduce((acc, person) > (acc + person.age), 0);

Interlude: a note about arrow functions

Filter an array

var adults  [];for (var i  0; i < people.length; i++) {
  if (people[i].age > 16) {
    adults.push(people[i]);
  }
}
const adults  people.filter(person > person.age > 16);

Find the element with max property

var oldest  {age: 0};for (var i  0; i < people.length; i++) {
  if (people[i].age > oldest.age) {
    oldest  people[i];
  }
}
const oldest  people.reduce((acc, person) > 
  person.age > acc.age ? person : acc
);

Extract a property from an array of objects

var names  [];for (var i  0; i < people.length; i++) {
  names.push(people[i].name);
}
const names  people.map(val > val.name);

Index an array of objects

var iPeople  {};for (var i  0; i < people.length; i++) {
  iPeople[people[i].id]  people[i];
}
const iPeople  people.reduce((acc, person) > {
  acc[person.id]  person;
  return acc;
}, {});

Find an element in array

var details  null;for (var i  0; i < people.length; i++) {
  if (people[i].name == 'Bob'){
    details  people[i];
    break;
  }
}
const details  people.find(val > val.name == 'Bob');

Summary

Subscribe for Email Updates:

Categories:

Tags:

Nexus vs SAFe
predictability
Slides
Agile Risk Management
Continuous Planning
Quality Assurance
Agile Product Ownership
Agile Project
ART Success
Daily Scrum
ARTs
RSA
Large Scale Scrum
Sprint Planning
System Team
DevOps
The Agile Coach
Lean Risk Management
GanttBan
Software Development
Agility
Jira admin
Agile Outsourcing
chatgpt
Frameworks
Story Slicing
Lean Agile Management
Tools
Agile Games and Exercises
TDD
Kaizen Workshop
WIP
Principles of Lean-Agile Leadership
SAFe DevOps
Releases Using Lean
Agile
Video
Agile India
Kanban Kickstart Example
Perfection Game
Agile Testing Practices
System Integration Environments
Change Management
Scrum.org
Nexus and SAFe
Lean Budgeting
Continuous Integration
Scrum Primer
BDD
Business Agility
System Archetypes
What Is Kanban
Retrospectives
Agile Techniques
Covid19
Nexus
Iterative Incremental Development
ScrumMaster Tales
Product Ownership
Lean-Agile Software Development
Development Value Streams
SAFe
Agile Product Development
An Appreciative Retrospective
Value Streams
Jira
Scrum Master
Test Driven Development
PI Objectives
NIT
Rapid RTC
Accelerate Value Delivery At Scale
Lean Agile Organization
QA
IT Operations
Scrum and XP
Agile Games
Professional Scrum with Kanban
Software Development Estimation
Scrum
Lean Startup
Kanban Game
SAFe Release Planning
Scrum Master Role
Lean Agile Leadership
transformation
Agile Release Management
EOS®
Webinar
Atlassian
Amdocs
Legacy Enterprise
Process Improvement
Professional Scrum Master
Pomodoro Technique
Agile in the Enterprise
A Kanban System for Software Engineering
Scrum Values
Jira Cloud
Acceptance Test-Driven Development
Hybrid Work
Implementing SAFe
Kanban
Agile Israel Events
Risk Management in Kanban
Agile Marketing
Engineering Practices
Code
Introduction to ATDD
Nexus Integration Team
Certified SAFe
Kaizen
Spotify
Scrum Guide
Program Increment
Agile Program
ALM Tools
Rovo
User stories
Agile Contracts Best Practices
Operational Value Stream
AI Artificial Intelligence
speed @ scale
Risk-aware Product Development
PI Planning
Presentation
Elastic Leadership
Agile Exercises
AgileSparks
Nexus and Kanban
Agile Assembly Architecture
Confluence
Kanban Basics
Managing Risk on Agile Projects
Advanced Roadmaps
lean agile change management
Manage Budget Creation
Self-organization
Agile Release Planning
Lean and Agile Principles and Practices
Agile for Embedded Systems
Agile Delivery
Planning
Built-In Quality
Kanban 101
speed at scale
ROI
Lean Agile
Portfolio for Jira
SA
Lean Software Development
Implementation of Lean and Agile
Agile Basics
Applying Agile Methodology
Artificial Intelligence
Jira Plans
Sprint Retrospectives
Limiting Work in Progress
Risk Management on Agile Projects
Achieve Business Agility
POPM
Agile Mindset
Tips
Games and Exercises
Reading List
Managing Projects
Agile Development
Agile and DevOps Journey
SPC
ATDD
Keith Sawyer
Continuous Delivery
Scaled Agile Framework
Lean-Agile Budgeting
Sprint Iteration
Agile Project Management
Agile Israel
Systems Thinking
Effective Agile Retrospectives
RTE
Coaching Agile Teams
Professional Scrum Product Owner
Continuous Improvement
ATDD vs. BDD
Lean and Agile Techniques
AI
LAB
Product Management
Entrepreneurial Operating System®
Enterprise DevOps
Legacy Code
Certification
Lean Agile Basics
Atlaassian
LPM
Introduction to Test Driven Development
Continuous Deployment
agileisrael
Agile Community
The Kanban Method
Scrum With Kanban
RTE Role
Team Flow
Release Train Engineer
AgileSparks
Logo
Enable registration in settings - general

Contact Us

Request for additional information and prices

AgileSparks Newsletter

Subscribe to our newsletter, and stay updated on the latest Agile news and events

This website uses Cookies to provide a better experience
Shopping cart