dimanche 4 juillet 2021

concat is not defined error when printing function to console

I'm getting an error below when running the below code, the code works until the last function where this error occurs. The code is to pick a random number and random words from the beginning functions and then concatenate them in the final function as one string, the output should be something like: 7 happy cats jumping.

ReferenceError: concat is not defined

//function to generate and display to console Word 1 - Random Number.
function Word1(min, max) {
    min = Math.ceil(1);
    max = Math.floor(9);
    return Math.floor(Math.random() * (max - min)) + min;
}
const Random_Number = Word1()
console.log(Random_Number);

//Function to generate and display to console Word 2 - Random Emotion.
function Word2(word)
{
    return word[Math.floor(Math.random() * word.length)];
}

var word = ["Happiness", "Sadness", "Fear", "Disgust", "Anger", "Suprise"];
console.log(Word2(word));


//Function to generate and display to console Word 3 - Random plural noun.
function Word3(noun)
{
    return noun[Math.floor(Math.random() * noun.length)];
}

var noun = ["Noun", "Monday", "Program", "Pizza", "Computer", "Suprise"];
console.log(Word3(noun)+ "s");

//Function to generate and display to console Word 4 - Random verb.
function Word4(verb)
{
    return verb[Math.floor(Math.random() * verb.length)];
}

var verb = ["Accept", "Hope", "Jump", "Lend", "Relax", "Damage"];
console.log(Word4(verb));
 
//Function to create password one-line string.
function password(passWord)
{
    return passWord[concat(Word1 + " " + Word2 + " " + Word3 + " " + Word4)];
}
var passWord = password();
console.log(password);



Aucun commentaire:

Enregistrer un commentaire