You can do it in a number of ways, this is how I would do it:
const Cards = {
1: { val: "this is the value 1" },
2: { val: "this is the value 2" },
3: { val: "this is the value 3" },
4: { val: "target" },
5: { val: "this is the value 5" },
6: { val: "this is the value 6" },
7: { val: "target" },
};
// start searching the target from here
const start = 2;
const entries = Object.entries(Cards);
// we start from 2 and in 4 we reach the first target so in 4 we should break the loop
for (let i = start; i < entries.length; i++) {
const [key, value] = entries[i];
console.log(value.val);
}
CLICK HERE to find out more related problems solutions.