Perform type coercion at the beginning of the statement.
// => this.reviewScore = 9;
// bad
var totalScore = this.reviewScore + '';
// good
var totalScore = '' + this.reviewScore;
// bad
var totalScore = '' + this.reviewScore + ' total score';
// good
var totalScore = this.reviewScore + ' total score';
By their own rule, shouldn't these be bad/good/good/bad?
I see what you mean. They're still coercing the type, just with a string at the end of the statement, though. If they mean what you mean, they should say something like "Perform 'standlone' type coercion, when necessary, at the beginning of the statement, but omit if it's not needed".
2
u/pimlottc Mar 27 '15
By their own rule, shouldn't these be bad/good/good/bad?