I am wanting to loop through an object and make some changes to the data. Im not 100% if im actually dealing with an object or an array that contains multiple object so any help appreciated.
Here is my object:
var screening = {
source: "jacket",
value: {
Cyan: {
dotshape: "C",
frequency: 120,
angle: 67.5
},
Magenta: {
dotshape: "C",
frequency: 120,
angle: 37.5
},
Yellow: {
dotshape: "C",
frequency: 120,
angle: 82.5
},
"PANTONE 3528 C": {
dotshape: "C",
frequency: 120,
angle: 7.5
},
"PANTONE 293 C": {
dotshape: "C",
frequency: 120,
angle: 7.5
},
"PANTONE 2748 C": {
dotshape: "C",
frequency: 120,
angle: 7.5
},
Varnish: {
dotshape: "C",
frequency: 120,
angle: 0
}
}
}
Inside i want to essentially do a find and replace of the 'keys'(again not sure on the terminology) based on 2 lists.
Old = [Cyan, Magenta, Yellow]
new = [changedName1, changedName2, changedName3]
Ideally i want the loop to look at the current object, if it has a match to something in the array Old then rename it as per the New. If there is no match to something in the array Old then just ignore it and leave it as it is.
Thanks in advance