@@ -216,22 +216,24 @@ Example usage of the output to highlight error in input:
216
216
217
217
` ` ` js
218
218
let inputRenderIndex = 0 ;
219
+
219
220
for (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) {
222
223
const unchangedInput = document .createElement (' span' );
223
224
unchangedInput .textContent = input .substring (inputRenderIndex, correction .startIndex );
224
225
editBox .append (unchangedInput);
225
226
}
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.
227
228
const errorInput = document .createElement (' span' );
228
229
errorInput .textContent = input .substring (correction .startIndex , correction .endIndex );
229
- errorInput .classList .add (' red ' );
230
+ errorInput .classList .add (' error ' );
230
231
editBox .append (errorInput);
231
232
inputRenderIndex = correction .endIndex ;
232
233
}
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 ){
235
237
const unchangedInput = document .createElement (' span' );
236
238
unchangedInput .textContent = input .substring (inputRenderIndex, input .length );
237
239
editBox .append (unchangedInput);
0 commit comments