My teacher made an array in my javascript file that i am not allowed to change. I am supposed to add new objects to it trough code without touching that array.
This is what my array looks like:
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 tried to make it like this:
function addCustomWord(object) {
const words2 = [{
dutch: "testDutch",
english: "testEnglish",
dutchDescription: "dutchDiscriptionTest",
englishDescription: "englishDiscriptionTest",
isknown: false
}]
words.push(words2);
}
That clearly doesn't work and i am having a hard time trying to find anything that actualy works. I have been trying very different solutions for hours and i can't find anything that works. Could someone help me with my problem?
Remove the square brackets from words2 because words two is the element you need to add