1. I want ratingClass = 'fresh' if rating > 59 OR if audience_rating > 70. How?
I tried with
if (rating > 59) || (audience_rating > 70) {
var ratingClass = 'fresh';
Here's the code:
if (rating > 59) {
var ratingClass = 'fresh';
} else if (rating > 0){
var ratingClass = 'rotten';
} else {
var ratingClass = 'na';
}
if (audience_rating > 59) {
var audienceClass = 'fresh';
} else if (audience_rating > 0){
var audienceClass = 'rotten';
} else {
var audienceClass = 'na';
}
$parentEl.addClass(ratingClass);
2. In line 114 of http://pastebin.com/UN8wcB7b I get Uncaught TypeError: Cannot read property 'length' of undefined every ~3 seconds when hideRotten = true. Is it easily fixed and/or do I need to worry about it at all?
I am new to JavaScript coding, currently I am trying to learn by doing. Can you recommend any resources to learn writing Chrome Extensions with JavaScript?
Thanks :-)
if (data.movies.length > 0) {=>if (data.movies && data.movies.length) {to avoid errors if there are no movies.ifblock. Once declared, it is visible in all the blocks, regardles of theifresult.