Regular expressions - JavaScript | MDN
To practice more JavaScript, I choose to do this thing:
As I opened the example, I could understand the general logic but still confused about the detailed syntax. And I asked chatGPT, especially this line, since I am new to split() and regex:
words = s.split(/(\\W+)/
GPT is good at explaining things.
Created resetHighlight function
Defined a data-original attribute to store the original text
Show the index of the text when hovered
Link here: https://editor.p5js.org/cy1503/sketches/xkIYI_l6-