1

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?

5
  • 2
    This question appears to be off-topic because it is about a simple typographic error. Commented Nov 18, 2013 at 19:12
  • 1
    @Pointy, but you still answered it anyway? Kind of defeats the purpose of dissuading newcomers to post this type of question if you're just going to answer it anyway. 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 comment. I didn't put a lot of deep thought into the situation :) 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. Commented Nov 18, 2013 at 19:15
  • jslint.com or jshint.com or use your debugger which will point you to the line. Commented Nov 18, 2013 at 19:15

3 Answers 3

6

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

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks! (Can't upvote your answer because of the 15 reputation limit...)
1
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.

Comments

0

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.

2 Comments

So where i searched 'js randomizing between numbers' didn't know that... But thanks for the tip! :)
@avaragecoder There is a depressing amount of really badly programmed example Javascript code around. Be careful of copying stuff from random sites. Because Javascript is often used by non-programmers, who hack and share code around, the quality is often terrible. If you can, get hold of Douglas Crockford's book on Javascript, he shows how it should be used in a safe and professional manner, that will give you a good foundation, at least.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.