Skip to content

Using Array.map() without using currentValue (no-unused-vars) #1970

Closed
@borrascador

Description

@borrascador

I'm in a situation where I'm trying to make an array of random x y coordinates but the underscore in the map function is being flagged as an unused var. I'm not sure if there is a better way to write this or if I should simply do an inline ignore in this case.

In short: how do I avoid the no-unused-vars error when I don't need the currentValue required by the Array.map() method?

const getRandomInt = max => Math.floor(Math.random() * Math.floor(max));
const myCoolArray = new Array(25)
  .fill({})
  .map(_ => ({
    x: getRandomInt(100),
    y: getRandomInt(100)
  }))

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions