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

156
Views
Odin project's task to make a function 'capitalize' and I have no idea if my answer is any good?

So I've been doing the Odin Project and I'm at functions right now and there's a task "Write a function called capitalize that takes a string and returns that string with only the first letter capitalized. Make sure that it can take strings that are lowercase, UPPERCASE or BoTh."

<script>
     

     function capitalize(myName, myNameUpper, myNameRan) {
     const toUpper = "Bartek";
     myName = "bartek";
     myNameUpper = "BARTEK";
     myNameRan = "BaRtEk";
     myName, myNameUpper, myNameRan = toUpper;
     console.log(myName, myNameUpper, myNameRan)
     
     }

     capitalize();
    
    
     
      </script>

Is my function any good? Thanks in advance for help.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

<script>
     

     function capitalize(lowercase,uppercase,both ) {
     const capitalizeLower = lowercase.charAt(0).toUpperCase() + lowercase.slice(1).toLowerCase();
     const capitalizeUpper = uppercase.charAt(0).toUpperCase() + uppercase.slice(1).toLowerCase();
     const capitalizeBoth = both.charAt(0).toUpperCase() + both.slice(1).toLowerCase();
     console.log(capitalizeLower, capitalizeUpper , capitalizeBoth)
     return `${capitalizeLower} ${capitalizeUpper} ${capitalizeBoth}`
     }

     capitalize("hello","HELLO","hEllO");
    
    
     
      </script>
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!