I am new to JavaScript and webdevelopment and am currently doing a course with Codecademy. I am creating a random message app that has an array of objects and prints a random message on run.
I have created the array of objects as follows:
const quoteMessage = [
{ title : "It’s up to you.",
meaning : "This one speaks for itself, really. No one is going to achieve your dream for you, and likewise, no one can stop you. It’s up to you.",
aurthor : "Unknown.",
},
{ title : "Failure is the opportunity to begin again more intelligently.",
meaning : "For being only nine words long, this is an incredibly powerful, thought-provoking quote. It’s also incredibly accurate if you take the time to think about it. With every failure, we learn and grow, meaning that when we start over we’re almost guaranteed to do a better job. Failure isn’t a step back; it’s a step forward.",
aurthor : "Henry Ford.",
},
{ title : "The best revenge is massive success.",
meaning : "It can be hard not to lash out at the people who tell you that you’re never going to succeed. However, if you let anger and hatred consume you, you’re never going to get anywhere and you’ll just prove them right. Rather than shout and swear, why not watch their faces as you mount that last step and reach the top?",
aurthor : "Unknown.",
}];
I have created the random selector as follows:
console.log(quoteMessage[Math.floor(Math.random()*(quoteMessage.length - 1))]);
I am copying and pasting this code directly into the console. When I run the code I get an error:
Uncaught SyntaxError: Identifier 'quoteMessage' has already been declared.
I don't understand why I am getting this error. What am I doing wrong?