Cannot understand how the ternary op works here

So I solve this challenge:

using a combination of .filter and .map, but I can’t really figure out how the second solution works, can anyone help me translate it into plain English?

const squareList = arr => {
  return arr.reduce((sqrIntegers, num) => {
    return Number.isInteger(num) && num > 0
      ? sqrIntegers.concat(num * num)
      : sqrIntegers;
  }, []);

from the third line: if num is an integer bigger than zero, concat num * num it to sqrIntegers; if not… :thinking: :thinking: :thinking: what?

…then just return the current value of sqrIntegers, ignoring the current value (ie do nothing and go on to the next value). The callback function for reduce has to return the accumulator, as that value is what gets passed in the next time the function is called

1 Like

Ahhh, I see now. Interesting way to solve this. Thank you