Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
<a href="https://github.com/jrobbins/computer-science">See GitHub home page</a>
<br>
<a href="wordlist_grouped.html">Grouped Word List</a>
3 changes: 3 additions & 0 deletions wordlist.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

48 changes: 48 additions & 0 deletions wordlist_grouped.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Grouped Word List</title>
<script src="wordlist.js"></script>
</head>
<body>
<h1>Word List Grouped by First Letter</h1>

<script>
// Ensure the DOM is fully loaded before trying to manipulate it,
// though in this case, script is at the end of body, so it's mostly fine.
document.addEventListener('DOMContentLoaded', () => {
if (typeof wordsByFirstLetter === 'undefined' || !(wordsByFirstLetter instanceof Map)) {
console.error('wordsByFirstLetter is not defined or not a Map. Make sure wordlist.js is loaded and defines it.');
const errorMsg = document.createElement('p');
errorMsg.textContent = 'Error: Could not load or process the word list. See console for details.';
document.body.appendChild(errorMsg);
return;
}

const container = document.createElement('div');
document.body.appendChild(container);

// Sort the keys (letters) alphabetically
const sortedLetters = Array.from(wordsByFirstLetter.keys()).sort();

for (const letter of sortedLetters) {
const words = wordsByFirstLetter.get(letter);

const letterHeading = document.createElement('h2');
letterHeading.textContent = letter.toUpperCase();
container.appendChild(letterHeading);

const wordUl = document.createElement('ul');
for (const word of words) {
const wordLi = document.createElement('li');
wordLi.textContent = word;
wordUl.appendChild(wordLi);
}
container.appendChild(wordUl);
}
});
</script>
</body>
</html>