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

328
Vistas
How can I change a string to be all lowecase and push something to the end?

So I have a function that will be called with a 1 word string. Test("ABCD")

my code:

function Test(x)

    var str=""
    str.push($)
    x.toLowerCase()
    return str

//So I want the output to change the "ABCD" into "abcd$"

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

You are accepting the argument x in the function and running toLowerCase on it. The output is not having any value from the input.

Also there is no push method defined for string. It can be String.concat. Even that is not needed, you could make use of arithematic + itsel for concatenation or string leterals.

Just lowercase the input append a $ symbol. Its done!!

Im making use of .toString() method aswell. To ensure code is not breaking for other input types

It should be

function Test(x) {
  return x.toString().toLowerCase() + '$'
}
console.log(Test("ABCD"));

Or Simply.

Test = (x) => `${ x.toString().toLowerCase() }$`;
console.log(Test("ABCD"));

about 4 years ago · Juan Pablo Isaza Denunciar

0

This is just an example, please change the text which you want to add at end as you wish.

I passed the string in function through console.log but you can call the function as you wish without console.log.

function capFirst(str) {
     return str.toLowerCase().concat('', '$');
 }

console.log(capFirst('ABCD'));

about 4 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 Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda