Tell me more ×
Code Review Stack Exchange is a question and answer site for peer programmer code reviews. It's 100% free, no registration required.

I do hope my question fits here, because I read the FAQ but it isn't clear to me whether I should run code errors here. Anyway, this snippet (extracted from a project I work on) is giving me a hard time. When checking in JSFiddle it tells me that it expected } for closing the animate({ but instead found 300, but that doesn't make sense because there is nothing to match, animate is already closed.

Console then, tells me that the comma before 300 was unexpected. I really don't understand the problem with it!

var condition = offL > ((wW / 2) - $this.width()),
  propertiesAnim = [],
  propertiesCss = [];

if (condtion) {
  properties = "'left': offL - tooltip.width() - 25";
  propertiesCss = "'right', 'auto'";
} else {
  properties = "'right': offR - tooltip.width() - 25";
  propertiesCss = "'left', 'auto'";
}

tooltip.stop(true).css(propertiesCss).text(title).animate({
  "top": ($this.offset().top + (posT / 2) - (tooltip.height() / 2)),
  properties
}, 300).fadeTo(200, 1); // Error
share|improve this question
1  
Well the FAQ clearly states that this is off topic: β€œTo the best of my knowledge, does the code work?” – no, it does not. => Off topic. – Konrad Rudolph Jan 13 at 13:43

closed as off topic by Konrad Rudolph, palacsint, sepp2k Jan 13 at 16:12

Questions on Code Review Stack Exchange are expected to relate to code review request within the scope defined in the FAQ. Consider editing the question or leaving comments for improvement if you believe the question can be reworded to fit within the scope. Read more about closed questions here.

1 Answer

Unexpected } - because you have

{
  "top": ($this.offset().top + (posT / 2) - (tooltip.height() / 2)),
  properties
}

What JS expects is a colon after properties and a value for the properties field.

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.