简体   繁体   English

Javascript“未捕获的SyntaxError:意外的令牌;”错误

[英]Javascript “Uncaught SyntaxError: Unexpected token ;” error

When i run this code it gives a syntax error in Chrome. 当我运行此代码时,它在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? 它与方法名称的长度有关还是我只是忘记了一些分号?

You've got a ; 你有一个; inside the console.log() call in that function. 里面 console.log()在函数中调用。

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. 半冒号位于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. 并非严格要求使用它们,但是如果Javascript不知道一条语句何时结束而另一条语句开始,则没有它们就可以提交各种难以发现的错误。 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. 这实际上是导致错误消息的原因。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM