JavaScript array returning unidentified [closed]

Hi I’m needing some help I’m pretty new to coding I can’t seem to get my function to work it keeps returning undefined, any tips would be appreciated. thanks

var german = ["eins","zwei","drei","vier","fünf","sechs","sieben","acht","neun","zehn","elf","zwölf","dreizehn","vierzehn","fünfzehn","sechzehn","siebzehn","achtzehn","neunzehn","zwanzig","einundzwanzig","zweiundzwanzig","dreiundzwanzig","vierundzwanzig","fünfundzwanzig","sechsundzwanzig","siebenundzwanzig","achtundzwanzig","neunundzwanzig","dreiβig"];
var french = ["un","duex","trois","quatre","cinq","six","sept","huit","neuf","dix","onze","douze","treize","quatorze","quinze","seize","dix-sept","dix-huit","dix-neuf","vingt","vingt et un","vingt-deux","vingt-trois","vingt-quatre","vingt-cinq","vingt-six","vingt-sept","vingt-huit","vingt-neuf","trente"];

var translatedNumber = translate();


var number = prompt("Please enter a number between 1-30 to be translated");
    if (number > 30 || number < 1) {
        alert("Please enter a number between 1-30")
        exit()
    }
    else if(isNaN(number)){
        alert("Please enter digits")
        exit()
    }


var language = prompt("Translated into what language? French/German");

    if (language == "german" || language == "french"){
    translate();
    } 
    else{
    alert("Only French or German is allowed")
    exit()
    }

function translate(number,language,translatedNumber,french,german){
    if(language == "german"){
        var translatedNumber = german[number - 1];
        }
    
    else if(language == "french"){
        var translatedNumber = french[number - 1];
        }
    return translatedNumber;
}

alert("The translation is " + translatedNumber);

Answer

Fixed it:

(The problem was you didn’t set up your function properly. I changed the translate function variables to lan and num since those are the only two you use in the function. Also I didn’t think you needed to define the translatedNumber at the top yet since you have not used it yet) Hope this helps :D.)

var german = ["eins","zwei","drei","vier","fünf","sechs","sieben","acht","neun","zehn","elf","zwölf","dreizehn","vierzehn","fünfzehn","sechzehn","siebzehn","achtzehn","neunzehn","zwanzig","einundzwanzig","zweiundzwanzig","dreiundzwanzig","vierundzwanzig","fünfundzwanzig","sechsundzwanzig","siebenundzwanzig","achtundzwanzig","neunundzwanzig","dreiβig"];
var french = ["un","duex","trois","quatre","cinq","six","sept","huit","neuf","dix","onze","douze","treize","quatorze","quinze","seize","dix-sept","dix-huit","dix-neuf","vingt","vingt et un","vingt-deux","vingt-trois","vingt-quatre","vingt-cinq","vingt-six","vingt-sept","vingt-huit","vingt-neuf","trente"];

var translatedNumber;


var number = prompt("Please enter a number between 1-30 to be translated");
    if (number > 30 || number < 1) {
        alert("Please enter a number between 1-30")
        exit()
    }
    else if(isNaN(number)){
        alert("Please enter digits")
        exit()
    }


var language = prompt("Translated into what language? French/German");

    if (language == "german" || language == "french"){
    translate(language, number);
    } 
    else{
    alert("Only French or German is allowed")
    exit()
    }

function translate(lan, num){
    if(lan == "german"){
        translatedNumber = german[num - 1];
        } else if(lan == "french"){
        translatedNumber = french[num - 1];
        }
    return translatedNumber;
}

alert("The translation is " + translatedNumber);