Skip to content

Commit

Permalink
chore: added additional comments
Browse files Browse the repository at this point in the history
  • Loading branch information
AskeLange committed Jan 29, 2025
1 parent e90ee65 commit 8fd2bc2
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions 8-1-split-text/script.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
document.addEventListener("DOMContentLoaded", function () {
const items = document.querySelectorAll(".target");
const splitWords = document.querySelectorAll(".target-words");
var items = document.querySelectorAll(".target");
var splitWords = document.querySelectorAll(".target-words");

/**
* Splits each word into individual characters.
*/
items.forEach((item) => {
let index = 0;
var index = 0;
var text = item.textContent;

const text = item.textContent;
item.innerHTML = text
.split(" ")
.map((word) => {
Expand All @@ -17,10 +20,13 @@ document.addEventListener("DOMContentLoaded", function () {
.join(" ");
});

/**
* Splits each character into individual characters, taking words into account.
*/
splitWords.forEach((item) => {
let index = 0;
var index = 0;
var text = item.textContent;

const text = item.textContent;
item.innerHTML = text
.split(" ")
.map((char) => `<span style="--index:${index++}">${char}</span>`)
Expand Down

0 comments on commit 8fd2bc2

Please sign in to comment.