Skip to content

Commit d263bfb

Browse files
authored
Merge pull request #4 from tomayac/patch-3
Fix code sample
2 parents 9b2fb97 + d46649c commit d263bfb

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

README.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -216,22 +216,24 @@ Example usage of the output to highlight error in input:
216216
217217
```js
218218
let inputRenderIndex = 0;
219+
219220
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) {
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

Comments
 (0)