From 8fd2bc2299487cdf4759bfcdf14f116acf3c8ce3 Mon Sep 17 00:00:00 2001 From: Aske Lange <44546482+AskeLange@users.noreply.github.com> Date: Wed, 29 Jan 2025 12:52:22 +0100 Subject: [PATCH] chore: added additional comments --- 8-1-split-text/script.js | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/8-1-split-text/script.js b/8-1-split-text/script.js index a1a75d9..4129fff 100644 --- a/8-1-split-text/script.js +++ b/8-1-split-text/script.js @@ -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) => { @@ -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) => `${char}`)