Wrap a ternary expression in parens, with a line break after the left paren

316 Views Asked by At

jslint is telling me to do this:

Wrap a ternary expression in parens, with a line break after the left paren.

To this line: "wrapper": (index < allWrappers.length) ? allWrappers[index] : allWrappers[allWrappers.length - 1]

Inside here:

  function findPlayers() {
    const allCovers = document.querySelectorAll(".cover");
    const allWrappers = document.querySelectorAll(".wrap");
    allCovers.forEach(function addToPlayers(cover, index) {
      players.push({
        "cover": cover,
        "wrapper": (index < allWrappers.length) ? allWrappers[index] : allWrappers[allWrappers.length - 1]
      });
    });
  }

What would that line get changed to?

1

There are 1 best solutions below

0
Nicholas Tower On BEST ANSWER

It wants you to do this:

"wrapper": (
  (index < allWrappers.length) ? allWrappers[index] : allWrappers[allWrappers.length - 1]
)