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?
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?
Share Improve this question asked Nov 18, 2013 at 19:11 ooransoyooransoy 7975 gold badges10 silver badges26 bronze badges 5- 2 This question appears to be off-topic because it is about a simple typographic error. – Pointy Commented Nov 18, 2013 at 19:12
- 1 @Pointy, but you still answered it anyway? Kind of defeats the purpose of dissuading newers to post this type of question if you're just going to answer it anyway. – maček Commented Nov 18, 2013 at 19:13
- @maček well the point of closing "typo questions" is that they don't do anybody any good as a long-term reference question, but this person still had a problem to be solved. I suppose I could have just typed a ment. I didn't put a lot of deep thought into the situation :) – Pointy Commented Nov 18, 2013 at 19:14
-
1
Aside from the obvious syntax error, presumably you have put the
console.log
there to see why it's not working - if it isn't obvious the function has no return statement. – Emissary Commented Nov 18, 2013 at 19:15 - jslint. or jshint. or use your debugger which will point you to the line. – epascarello Commented Nov 18, 2013 at 19:15
3 Answers
Reset to default 6You've got a ;
inside the console.log()
call in that function.
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.
Semi colons go at the end of each statement in Javascript. You're missing them.
They're not strictly required, but you can mit 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.