Skip to content
Sign upLog in
← Back to Community

SyntaxError: Unexpected token '<'

Profile icon
tymergoss

https://repl.it/join/guzonkcv-tymergoss

I've tried everything I can think of. Searched around the web to try and locate a solution. Everything I try just ends up coming up with another syntax error. My assignment is over due and I need help so I can turn it in for partial credit

Voters
Profile icon
tymergoss
Comments
hotnewtop
Profile icon
Coder100

did you just copy and paste code lol

That's not valid syntax, you must actually have the variable like this:

var b = "apple"; console.log("a" + b);

Here's the working code:

function makeInsult() { var words1 = ["artless", "bootless", "clouted", "clouted", "errant"]; var words2 = ["beef-witted", "dismal-dreaming", "fat-kidneyed", "half-faced", "tickle-brained"]; var words3 = ["barnacle", "death-token", "foot-licker", "measle", "varlot"]; var rand1 = Math.floor(Math.random() * words1.length); var rand2 = Math.floor(Math.random() * words2.length); var rand3 = Math.floor(Math.random() * words3.length); let w1 = words1[rand1]; let w2 = words2[rand2]; let w3 = words3[rand3]; var insult = "Thou " + w1 + " " + w2 + " " + w3 + "!"; return insult; }
Profile icon
tymergoss

@Coder100
I copied the code from phrase-o-matic. That was the first part of our task one and then our instructor wanted us to use the same code for insult-o-matic, but change how the phrase is generated. Thanks for your help!

Profile icon
Coder100

np!
mark as correct answer please

@tymergoss

Profile icon
tymergoss

Correct answer.

@Coder100

Profile icon
tymergoss

my syntaxerror is appearing in my insult-o-matic.1.js file when you open the shell. Once you type in "dir" then "node insult-o-matic.1.js" the syntaxerror appears.