Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

190
Vistas
How to format half size with <sup> tag?

Below is a function for joining words. Given the first or last word could be a string like 7 1/2, how would I ensure that; if the word contains a fraction, format the fraction with (superscript) tags.. so it shows nicely like below?

export const joinWords = (words: string[]): string => {
    if (words.length === 1) {
        return words[0];
    }
    const firstWords = words.slice(0, words.length - 1);
    const lastWord = words[words.length - 1];
    const oxfordComma = words.length > 2;

    //if firstWords or lastword contains "/"...Logic???

    return firstWords.join(', ') + `${oxfordComma ? ', ' : ''} and ${lastWord}`;
};

enter image description here

about 4 years ago · Santiago Gelvez
1 Respuestas
Responde la pregunta

0

I found an alternate way, where I use the replace method. I am using svelte hence the onmount..

onMount(() => {
//join the words
        const test = joinWords(optionNames);
//replace the "1/2" since I am only using 1/2 for clothing sizes...this may not work for other fractions..
        const newTest = test.replace('1/2', '&frac12;');
        testWord = newTest;
    });
//be sure to return as html...again im in svelte.
<span>{@html testWord} </span><br />
about 4 years ago · Santiago Gelvez Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda