Why am I getting "Uncaught SyntaxError: Unexpected token *" here? [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 7 years ago.
Improve this question
I'm getting it for the * in the chunk of code
// click function for the "See More Scores" and "See Fewer Scores" buttons
$('.show-fewer-or-more-scores').click(function ( ) {
var rowsNotFirst = $(this).closest('tbody').children('tr:gt(0)');
// unravel the scores in an animated fashion
rowsNotFirst.filter(function (idx, el) {
setTimeout(function ( ) { $(el).toggleClass("hidden"); },
50 * idx);
});
});
and I don't see why. I put it in JSHint and was not alerted of any problems that would be causing this. Full code can be seen as commit bd4629b of https://github.com/jamkin/Snake/blob/master/SnakeGame/Scripts/game.js. You can also see the live bug here although it may be fixed if you're accessing this thread a day or more later than it was posted.
Any ideas what I've done wrong?

You have an artifact hanging around at the end of the file

var idx50 = 50*idx;
rowsNotFirst.filter(function (idx, el) {
setTimeout(function (){ $(el).toggleClass("hidden");}, idx50);

Related

does anyone know how to correct this 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 last year.
Improve this question
function tipCalculator(nonTipTotal)
{
var totalWithTip = nonTipTotal * 15;
console.log(`You should pay {totalWithTip} including tip`)
}
function tipCalculator();
It's supposed to print out the statement of the total with the tip included
Maybe this?
function tipCalculator(nonTipTotal) {
const totalWithTip = nonTipTotal * 1.15;
console.log(`You should pay ${totalWithTip} including tip`)
}
const billTotal = 25 // get your bill input somehow - depends how this runs
tipCalculator(billTotal);
You are missing the $ symbol before the opening curly bracket. It should be ${totalWithTip} instead of {totalWithTip}
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals

Why does JavaScript get this comparison wrong? [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
This is happening on an angular application I'm building. If a user enters 80 into an HTML input, it always seems to get this comparison wrong.
var x = '80';
var y = 150.9800;
/* Returns incorrect answer */
if (parceFloat(x) < y) {
return true;
} else {
return false;
}
You need to use ParseFloat() not parceFloat() ...
parceFloat is not an existing function.
parceFloat() is not a function, the function is parseFloat()
A simple typo is all the error there is.

OnRecordStart, line 2: SyntaxError: missing ) after condition [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
if (!AlreadyReadExternalFile ("T:\PRINT SHOP\WebCRD Templates\Mailing Labels\Office Address")
{
ExternalData=new ExternalDataFileEx(LookupFile, "T:\PRINT SHOP\WebCRD Templates\Mailing Labels\Office Address,");
AlreadyReadExternalFile = true;
if (!ExternalData.valid)
{
var Message = "External file NOT found: " + LookupFile;
Print(Message);
}
else
{
var Message = "External file found: " + LookupFile;
Print(Message);
}
I have no knowledge of writing code. I was told to replace a few items which I did and now the code doesn't seem to work. Can someone please direct me to what I'm missing.
First line should be this
if (!AlreadyReadExternalFile ("T:\PRINT SHOP\WebCRD Templates\Mailing Labels\Office Address"))
You were missing the closing parenthesis to the if statement. The first line has two opening parentheses which must be closed.

jQuery call incorrectly firing at the same time as fade [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 building a lightbox and am running into an issue where the following fadeIn function is firing at the same time as the fadeOut instead of afterwards.
Why is updateImage.call(this) firing at the same time as the fadeOut? Should it not fire afterwards considering it is placed as a callback?
Full code snippet
function updateImage() {
activeImage = overlayImagesBox.find('.' + this.className);
activeImage.fadeIn('slow').addClass('active-image');
}
imageLinks.on('click', function (e) {
e.preventDefault();
if (!activeImage) {
updateImage.call(this);
} else {
activeImage.removeClass('active-image').fadeOut('slow', updateImage.call(this));
activeImage = null;
}
});
As #blex mentioned in the comments the correct answer is simply passing the function as a callback instead of executing it. Thank you for the help everyone.

Javascript String.replace [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
Can someone please explain why this code isn't working?
(it has been simplified for this example)
$(document).ready(function () {
var test = 'broken';
test = test.replace('broken','working');
console.log(test); // working
var field = $('[for="tournament_name"]').html();
console.log(field); // Tournament Name:
console.log(typeof field); // string
field = field.relpace(':',''); // Uncaught TypeError: undefined is not a function
});
I don't understand why it is saying replace() is undefined?
I did read through the docs, what am I missing here?
Maybe it's a typo:
relpace --> replace

Categories

Resources