Why does this line work
$('#body-image').css("background-image", 'url('+ backgroundimage +')');
but not this one
$('#body-image').css("background-image", 'url('backgroundimage')');
or this one
$('#body-image').css("background-image", 'url(backgroundimage)');
backgroundimageis a JavaScript variable. The concatenation operator in JavaScript is +, so to put a string together with a variable, you do'some string ' + someVariable. Without the +’s, JavaScript wouldn’t know what to do with your variable (and in your third example, wouldn’t even know that it was a variable).