I'm trying to convert a PHP snippet in javascript:
function year_shortcode() {
    $fromYear = 2010;
    $thisYear = (int)date('Y');
    return $fromYear . (($fromYear != $thisYear) ? '-' . $thisYear : '');
} add_shortcode('year', 'year_shortcode');
What I've done so far is:
var fromYear='2010';
var thisYear= new Date().getFullYear();
if (fromYear=thisYear) {
    document.write(fromYear);
}
else {
    document.write(fromYear + '-' + thisYear);
}
I'd like to avoid the if and else statements and shorten it as I would in PHP.
 
    