Renaming Layers changes name

I have been trying to batch rename my layers using the developer console. My use case is - I want to identify all INSTANCE nodes in the current page and prepend a “E-” to all the matching layers. I am able to prepend the “E-” but it changes the layer name to [Node 4:247], etc.

My code is as -

const pencil = Figma.currentPage.findAll(n => n.type === “INSTANCE”).slice()
for(var j=0;j<=pencil.length;j++){
pencil[j].name= ":pencil2: "+pencil[j]
}

Can someone let me know what am I doing wrong. I am not very good with coding. Thanks in Advance!

const pencil = figma.currentPage.findAll(n => n.type === “INSTANCE”)
for(var j=0;j<=pencil.length;j++){
pencil[j].name= ":pencil2: "+pencil[j].name
}

Awesome! Thanks again. This worked :slight_smile: