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

111
Views
Can't finalize the function Camel Case

I can't understand where is first word on output..

function camelCase(str){

let string = '';
let arr = str.split(' ');
let oneStr = '';
let twoStr = '';
for (let i = 0; i < arr.length; i++) {
    
string1 = arr[i] ;

oneStr = string1[0].toUpperCase() + string1.slice(1);

}

return oneStr;
}

console.log(camelCase('camel case'));

Output: Case

Help please to finalize the code

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

0

On this line, use += operator to concatenate the strings:

oneStr += string1[0].toUpperCase() + string1.slice(1);
about 4 years ago · Juan Pablo Isaza Report

0

actually you assigned the result to string1 in each iteration, instead use += operator

function camelCase(str){

let string = '';
let arr = str.split(' ');
let oneStr = '';
let twoStr = '';
for (let i = 0; i < arr.length; i++) {
    
string1 = arr[i] ;

oneStr += string1[0].toUpperCase() + string1.slice(1);

}

return oneStr;
}

console.log(camelCase('camel case'));

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!