unique id - increment object name with 1, 2, 3 and etc

is there a way to create an object with a unique id/name each time, for example:

I'm trying to create a circles object but want it to increment each time its created - circles1, circles2, and etc. On click I need this to happen:

let circles = 0; const circleCoordinates = []; function onClickFunc(){ circles++; circleCoordinates.push({circles : {x: mouseX, y: mouseY}}); console.log(circles); // doesnt create circles1 and etc, just circles obj }


How to solve this?
Was this page helpful?