• Empleos
  • Sobre nosotros
  • profesionales
    • Inicio
    • Empleos
    • Cursos y retos
  • empresas
    • Inicio
    • Publicar vacante
    • Nuestro proceso
    • Precios
    • Evaluaciones
    • Nómina
    • Blog
    • Comercial
    • Calculadora de salario

0

268
Vistas
Why is charAt() not a function and newCase is undefined?

I'm working on some map() practice and am stuck. I am attempting to capitalize the first letter in each word.

I believe I am following the correct syntax for charAt() but it is getting word.charAt() is not a function.

const titleCased = () => {
    const cased = tutorials.map((string) => {
        return string.split(' ')
    })
    let newCase = cased.forEach((word) => {
        return word.charAt(0).toUpperCase() + word.slice(1)
    })
    return newCase
}

I'm not looking for an answer, I really wanna figure it out myself!

Hopefully someone can give me some tips though, when I run my debugger it completely skips past newCase as well.. I'm sure I a am misunderstanding my scope.

tutorials variable for ref.

const tutorials = [
    'what does the this keyword mean?',
    'What is the Constructor OO pattern?',
    'implementing Blockchain Web API',
    'The Test Driven Development Workflow',
    'What is NaN and how Can we Check for it',
    'What is the difference between stopPropagation and preventDefault?',
    'Immutable State and Pure Functions',
    'what is the difference between == and ===?',
    'what is the difference between event capturing and bubbling?',
    'what is JSONP?',
]

EDIT: Update

So this is where I've gotten, Phil(below) mentioned that my original forEach() funct now map() is doing nothing with the return value of the callback.

I am very new and doing my best, I'm struggling to understand how to relate the return value.

const titleCased = () => {
    const cased = tutorials.map((string) => {
        return string.split(' ')
    })
    let newCase = cased.map((word) => {
        return word[0].charAt(0).toUpperCase() + word[0].slice(1)
    })
    return newCase
}
about 3 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

I finally did the thing

function titleCased() {
    const cased = tutorials.map((cb) => {
        const newCase = cb
            .split(' ')
            .map((word) => {
                return word.charAt(0).toUpperCase() + word.slice(1)
            })
            .join(' ')

        return newCase
    })
    return cased
}
about 3 years ago · Juan Pablo Isaza 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 Nuestro proceso Comercial
Legal
Términos y condiciones Política de privacidad
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recomiéndame algunas ofertas
Necesito ayuda