Home How to loop through array with objects inside
Reply: 0

How to loop through array with objects inside

user634
1#
user634 Published in May 21, 2018, 2:59 am

Actually its working with simple array

let box1 =[01, 02, 03];
function hitMiss(box) {
  $("td").on("click", function(){
      let y = $(this).attr("id");

          if (box.find(boxId => boxId == y)) {
              $(this).addClass("yes");
              console.log("full");
              } else {
              $(this).addClass("no");
              console.log("empty");
     }
  });
};

codepen

But i need to use objects in array

let boxes = [
    { locations: [01, 02, 03]},
    { locations: [23, 24, 25]},
    { locations: [41, 42, 43]}
];
You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.313582 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO