Uncaught SyntaxError: missing ) after argument list [closed] - javascript

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 6 years ago.
Improve this question
Can't figure out what I'm doing wrong... here is my jquery code
<script>
$("#validationForm").submit(function(event) {
alert('test');
};
</script>

$("#validationForm").submit(function(event) {
alert('test');
};
^
Should be:
$("#validationForm").submit(function(event) {
alert('test');
});
If you see this error in your browser's Dev Tools, try clicking in its line, like: Syntax Error: Uncaught SyntaxError: missing ) after argument list file.js:1. When 1 is the line. It will show you where the error is.

Related

If/else statements not displaying correctly to console [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 5 years ago.
Improve this question
I'm trying to get the console to read "No goal!" but every time I run it, I get "Goal". I'm guessing there's some basic syntax error that I'm making?
let isSoccerFan = false;
if (isSoccerFan=true) {
console.log("Goal!");
} else{
console.log("No goal!")
}
Your code is not correct. Try this:
let isSoccerFan = false;
if (isSoccerFan) {
console.log('Goal!');
} else {
console.log('No goal!');
}

JavaScript giving nonsense errors [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 6 years ago.
Improve this question
So, me and a few friends are making a text adventure in JavaScript. in it, there is a possibility of the player using a heal spell, which runs the following code:
function heal() {
alert('You chant some ominous-sounding words, and your wounds heal');
alert('Hit points restored!');
hitPoints += 60;
blobsOfDoom -= 30;
burn();
MonsAtt();
Choose Spell();
}
Error Messages:
Firefox:
/*
Exception: SyntaxError: missing ; before statement
#Scratchpad/1:2703
*/
Chrome:
SyntaxError: Unexpected identifier.
Why is this error showing up? How do I fix it?
You cant have spaces in functions
Choose Spell();
Check your function declaration for ChooseSpell and any other occurances, and change them to a valid function name, like chooseSpell()

Jquery: Uncaught SyntaxError: missing ) after argument list [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 7 years ago.
Improve this question
I am not sure what causes this problem (thought I covered it correctly). What happens is that on click, it should apply the grow class (which is 0.8 seconds) and after that flip over. Else it reverses this proces.
$('.click').toggle(function(){
var self = this;
$(this).removeClass('normal');
$(this).addClass('grow');
setTimeout(function(){
$(self).addClass('flip')
}800); <-- getting my error here
},
function(){
$(this).removeClass('flip');
setTimeout(function(){
$(this).addClass('normal');
$(this).removeClass('grow');
}800);
});
Yet I get an error Uncaught SyntaxError: missing ) after argument list on the first setTimeout (and probably ont he second one) but I dont see why i missed a )
You are missing the , before the timeout amount.
setTimeout(function(){
$(self).addClass('flip')
}800);
should be
setTimeout(function(){
$(self).addClass('flip')
},800);

Syntax error: Unexpected token else: specific code [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
I am learning JavaScript on codeacademy and I came upon an error as I was doing a lesson and I could not figure out how to fix it. The error was
SyntaxError: Unexpected token else.
Here is my code:
sleepCheck = function (numHours) {
if (sleepCheck >= 8) {
return "You're getting plenty of sleep! Maybe even too much!";
} ;
else {
return "Get some more shut eye!";
} ;
} ;
sleepCheck(10) ;
sleepCheck(5) ;
sleepCheck(8) ;
This was supposed to be a sleep checker. I was learning about functions and the return keyword.
The issue is the ';' before the else and after the '}'

Why does JS throw unexpected error while re-writing a variable? [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.
This question was caused by a typo or a problem that can no longer be reproduced. While similar questions may be on-topic here, this one was resolved in a way less likely to help future readers.
Closed 8 years ago.
Improve this question
Error is:
function (a){var b,c,d,e=this[0];{if(arguments.length)return d=m.isFunction(a),this.each(function(c){var e;1===this.nodeType&&(e=d?a.call(this,c,m(this).val()):a,null==e?e="":"number"==typeof e?e+="":m.isArray(e)&&(e=m.map(e,function(a){return null==a?"":a+""})),b=m.valHooks[this.type]||m.valHooks[this.nodeName.toLowerCase()],b&&"set"in b&&void 0!==b.set(this,e,"value")||(this.value=e))});if(e)return b=m.valHooks[e.type]||m.valHooks[e.nodeName.toLowerCase()],b&&"get"in b&&void 0!==(c=b.get(e,"value"))?c:(c=e.value,"string"==typeof c?c.replace(lc,""):null==c?"":c)}}
What I am trying to do is to catch a variable on Focus Out:
$('.field').focusout(function() {
var date = $('.field').val;
console.log(date);
//Do something else
});
The HTML for field is:
<input type="text" class="field" />
Just a Typo...
val is a function. Use val()
Yes I know this question is not worth an answer, but otherwise someone will just transplant the comment as their own answer :)

Categories