A ternary that reproduces your if
/else
:
title = title == 'project' ? text + ': ' + this.projectTitle : this.projectTitle;
Though if you really want to shorten it:
title = (title == 'project' ? text + ': ' : '') + this.projectTitle;
References:
solved How to refactor my conditional statement? [closed]