When using JavaScript’s reduce, how do I skip an iteration?

You can just return previousValue

[0, 1, 2, 3, 4].reduce(function(previousValue, currentValue, currentIndex, array) {
  if(currentValue === "WHATEVER") {
    return previousValue;
  }
  return previousValue + currentValue;
});

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)