Change var in if else statement
HTML
<div class="big"></div>
<div class="small"></div>
<!--
swapping out var that is set in body
-->
<script>
// var;
// var color;
// var color =;
// var color = '';
//var color = 'cat';
var color = 'big';
//var color = 'small';
</script>
CSS
.big {height:100px;width:100px;background:#eaeaea;}
.small {height:50px;width:50px;background:#eaeaea;}
JavaScript
// you need to have the condition defined
// you can't run this w/o condition set
// this is bad
//} else if () {
//}
if ( typeof color === 'undefined' || color != 'big' || color != 'small' ) {
// if var color returns undefined, is not defined or is defined as something other than 'big' or 'small' set background to dark grey
$('.big,.small').css('background-color', '#333');
} else if ( color === 'big' ) {
// but if it is set to big do something
$('.big').css('background-color', '#fad400');
} else if ( color === 'small' ) {
// but if it is set to small do something
$('.small').css('background-color', '#fad400');
}
$('body').append('<div>' + color + '</div>')