ooransoy
ooransoy

Reputation: 797

Javascript "Uncaught SyntaxError: Unexpected token ;" error

When i run this code it gives a syntax error in Chrome.

var leanboo = confirm("RFT(ready for testing)?") // Co1,Cr1
console.log(leanboo)
var text = prompt("What are your thoughts of this Area?")
console.log(text)

function crashCourseTesterIdGenerator(min, max) {
console.log(Math.floor((Math.random() * max) + min);)
} //Co1,Cr2
var testermin = prompt("Id generating min:")
var testermax = prompt("Id generating max:")
console.log(crashCourseTesterIdGenerator(testermin, testermax))

Does it have to do with the method name length or am i just forgetting some semicolons?

Upvotes: 1

Views: 12704

Answers (3)

Ian
Ian

Reputation: 3709

Semi colons go at the end of each statement in Javascript. You're missing them.

They're not strictly required, but you can commit all kinds of hard-to-find errors without them where Javascript doesn't know when one statement ends and another begins. Best to make it a matter of personal law to always use them and you're future self will save lots of debugging time.

And then you have an extra one:

console.log(Math.floor((Math.random() * max) + min);)

before the end of the line. Which is actually causing the error message.

Upvotes: 0

darcher
darcher

Reputation: 3134

var leanboo = confirm("RFT(ready for testing)?"); // Co1,Cr1
console.log(leanboo);
var text = prompt("What are your thoughts of this Area?");
console.log(text);

function crashCourseTesterIdGenerator(min, max) {
console.log(Math.floor((Math.random() * max) + min));
} //Co1,Cr2
var testermin = prompt("Id generating min:");
var testermax = prompt("Id generating max:");
console.log(crashCourseTesterIdGenerator(testermin, testermax));

Should fix ya right up.

Upvotes: 1

Pointy
Pointy

Reputation: 414036

You've got a ; inside the console.log() call in that function.

Upvotes: 6

Related Questions