Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

196
Views
How can i select a certain array value for the .some function?

I've been trying to make a function that checks if a user already clicked on some kind of object. To do this i'am saving all of the correctly clicked objects in an array called "clicked". Then every time the user clicks on the screen, i want to check if the user did not click the same object again. So i tried to use the .some function. When a user clicks on the screen the .some function checks the whole array if the user is trying to click on the same coordinates as they did before. Except, because the array consists of multiple data inputs per object, the .some function returns after clicking two objects always true. I suspect this is because the name of the object ("stars" in this case) is always the same, and so is present in the array when clicking the second object.

Raw output of a single object in the array:

[Star]
{
    "x": 285,
    "y": 1000,
    "dx": 0,
    "dy": 0,
    "radius": 30,
    "minRadius": 30,
    "ring": {
        "x": 1650,
        "y": 350,
        "radius": 30,
        "initialRad": 30,
        "radiusTarget": 45,
        "counted": false
    },
    "color": "#FF0000"
}

]

I need the .some function to check if the coordinates of the users input are corresponding with the coordinates of the already clicked objects (stored in the "clicked" array). For now i tried this:

          isClicked = clicked.some(function(e){
            return e = click.x;
          });
          console.log(isClicked);

Where in this case the click values are being generated from the users input. It's the first time i'm trying to get .some work. Tried reading the documentation, but that didn't get me any further. Hopefully somebody here can!

TL;dr: .some function has to return true when a user already clicked on an object by comparing an array with previously clicked objects to the active coordinates the user clicks. Except the .some function always returns true, which i'm suspecting is because the name of the objects is always the same.

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!