Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

330
Views
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 answers
Answer question

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 Report

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!