@@ -216,22 +216,24 @@ Example usage of the output to highlight error in input:
216216
217217` ` ` js
218218let inputRenderIndex = 0 ;
219+
219220for (const correction of corrections) {
220- // render part of input that has no error
221- if (startIndex > inputRenderIndex) {
221+ // Render part of input that has no error.
222+ if (correction . startIndex > inputRenderIndex) {
222223 const unchangedInput = document .createElement (' span' );
223224 unchangedInput .textContent = input .substring (inputRenderIndex, correction .startIndex );
224225 editBox .append (unchangedInput);
225226 }
226- // render part of input that is an error, highlight in red
227+ // Render part of input that has an error and highlight as such.
227228 const errorInput = document .createElement (' span' );
228229 errorInput .textContent = input .substring (correction .startIndex , correction .endIndex );
229- errorInput .classList .add (' red ' );
230+ errorInput .classList .add (' error ' );
230231 editBox .append (errorInput);
231232 inputRenderIndex = correction .endIndex ;
232233}
233- // render rest of input that has no error
234- if (inputRenderIndex != input .length ){
234+
235+ // Render rest of input that has no error.
236+ if (inputRenderIndex !== input .length ){
235237 const unchangedInput = document .createElement (' span' );
236238 unchangedInput .textContent = input .substring (inputRenderIndex, input .length );
237239 editBox .append (unchangedInput);
0 commit comments