JSFiddle - React, Tailwind, and code Playground
by JeffC
HTML
<script src="https://getfirebug.com/firebug-lite-debug.js"></script>
JavaScript
var cats = [
[ "Wedding", "Invitations", "Save the Date", "Announcements", "Party Invitations", "Reception & Ceremony", "Gift Registry Cards", "Place Cards", "Thank You Cards", "RSVP Cards", "Address Labels & Envelope Seals", "Enclosure Cards" ],
[ "Personalized Stationery", "Thank You Notes", "Labels", "Gift Registry Cards", "Memo Pads", "Photo Cards" ],
[ "Occasions", "Birthdays", "General Gifts", "Thank You", "Summer Collection", "Wedding", "Baby & Kids", "Father's Day", "Grad Gifts", "Back to College", "Holiday", "Moving" ],
[ "Personalized Stamps", "Address Stamps" ],
[ "Baby & Kids", "Baby Shower Invitations", "Birth Announcements", "Birthday Party Invitations", "Baby Personal Stationery", "Kids Personal Stationery", "Baby Gift Registry Cards", "Thank You Cards" ],
[ "Invitations", "Baby Shower", "Bridal Shower", "Birthday Party", "Holiday Party", "Wedding", "Anniversary Party", "Graduation", "Party Invitations for Grown Ups" ]
];
var Categories = [];
// load
for (i = 0; i < cats.length; i++)
{
Categories.push({ Name: cats[i][0], Link: "", Subcategories: [], });
for (j = 1; j < cats[i].length; j++)
{
Categories[i].Subcategories.push({ Name: cats[i][j], Link: "" });
}
}
// print
for (i = 0; i < Categories.length; i++)
{
console.log(Categories[i].Name);
for (j = 0; j < Categories[i].Subcategories.length; j++)
{
console.log("-" + Categories[i].Subcategories[j].Name);
}
}