add keys + cap
All checks were successful
PDX Pecularities Server / deploy (push) Successful in 1s

This commit is contained in:
david 2025-04-07 20:27:59 -07:00
parent 45075f88dd
commit 01362715b9

View File

@ -9,6 +9,10 @@ const loadSection = (sectionName) =>{
.catch(error => console.error('Error loading JSON:', error));
}
function cap(str) {
return str.charAt(0).toUpperCase() + str.slice(1);
}
// Recursive function to handle strings, arrays, and objects
const renderItems = (items) => {
return items.map(item => {
@ -18,8 +22,8 @@ const renderItems = (items) => {
return renderItems(item); // recurse into nested array
} else if (typeof item === 'object') {
return `<p>${Object.entries(item).map(([key, value]) =>
`${value}`).join('<br>')}</p>`;
// `<strong>${key}:</strong> ${value}`).join('<br>')}</p>`;
// `${value}`).join('<br>')}</p>`;
`<strong>${cap(key)}:</strong> ${value}`).join('<br>')}</p>`;
} else {
return `<p>${String(item)}</p>`;
}