Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

325
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda