I have to do a translate function using a structure looking like:
let dict = [
{
en: "moon",
de: "der Mond",
hu: "hold",
rs: "mesec"
},
{
en: "fox",
de: "der Fuchs",
hu: "róka",
rs: "lisica"
},
{
en: "girl",
de: "das Mädchen",
hu: "lány",
rs: "devojka"
}
];
My function is:
function translate(word, from, to) {
return dict.find(x => x.from == word).to
}
And how I have to call the function:
translate("fox", "en", "hu")
My from
and to
parameters just don't want to work and givinig back undifined. If I call it directly like:
dict.find(x => x.en == "fox").hu
it gives me the right value, which is "róka".
I figured out maybe it's because of the quotes but I didn't find any solution anywhere.