Why this function gave me the undefined in javascript?

I am newbie to the javascript and I wrote the simple function below.
I am wonder that the function blow gave me the undefined. Is there any mistake in the function below?

function randFace() {
    return ["crown", "anchor", "heart", "spade", "club", "diamond"]
    [rand(0, 5)];
}

console.log(randFace())

9 thoughts on “Why this function gave me the undefined in javascript?”

Leave a Comment