Skip to content

Commit

Permalink
up
Browse files Browse the repository at this point in the history
  • Loading branch information
EspectroW94 committed Dec 28, 2024
1 parent bf22a98 commit 424a4ad
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions items/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,16 @@ Papa.parse('items.csv', {

const itemImage = document.createElement('img');
itemImage.classList.add('item-image');
// Obtener la primera letra y convertirla a mayúscula
const firstLetter = item.Icon[0].toUpperCase();
// Concatenar la primera letra en mayúscula con el resto del nombre
const imageName = firstLetter + item.Icon.slice(1);

if (item.Icon) {
// Expresión regular para encontrar palabras separadas por guiones bajos
const regex = /_(\w)/g;
// Capitalizar la primera letra de cada palabra
const imageName = item.Icon.replace(regex, (match, p1) => p1.toUpperCase());
itemImage.src = `assets/items/${imageName}`;
} else {
console.error("El nombre de la imagen no está definido.");
}

const itemName = document.createElement('h3');
itemName.classList.add('item-name');
Expand Down

0 comments on commit 424a4ad

Please sign in to comment.