My instructor set up an array in my JavaScript file that is off limits for me to modify. My task is to add new objects to it through code without directly manipulating the existing array.
Here's a snapshot of what my array contains:
const words = [{
dutch: "vork",
english: "Fork",
dutchDescription: "Iets waarmee je eet dat doorgaans vier tanden heeft.",
englishDescription: "Something you eat with that usually has four tines.",
isknown: false
},
{
dutch: "mes",
english: "knife",
dutchDescription: "Bestek dat snijdt.",
englishDescription: "Cutlery that cuts.",
isknown: false
},
{
dutch: "lepel",
english: "spoon",
dutchDescription: "Bestek waarmee je soep eet.",
englishDescription: "Cutlery you use to eat soup.",
isknown: false
}
];
I attempted to approach it this way:
function addCustomWord(object) {
const words2 = [{
dutch: "testDutch",
english: "testEnglish",
dutchDescription: "dutchDiscriptionTest",
englishDescription: "englishDiscriptionTest",
isknown: false
}]
words.push(words2);
}
The above method did not yield the desired results, and I am struggling to find a working solution. I have spent hours experimenting with various approaches but nothing seems to work as intended. Can someone provide assistance with resolving this issue?