Need help solving a problem

// Need help to turn the letter after '-' to uppercase 

function camelize(str){
    let newStr = str.split('-');
    // stuck on how to transform the letter after hyphen to uppercase
    // I know I need to apply join() after
    return newStr;
}

camelize("background-color") == 'backgroundColor';

Hello @hmahad

I wrote a simple func .
Try this please

function camelize(str){
    let pos = str.indexOf('-');
    let newStr = '';
    if( pos >-1) {
        newStr = str.substr(0,pos);
        if(str.length > pos+1 ) {
            newStr += str[pos+1].toUpperCase();
            newStr += str.substr(pos+2);
         }
    }
    else {
        newStr = str;
    }
    return newStr;
}

Thanks. It does the job but I’m gonna have through thru each line to understand what it does.

Hello again @hmahad
Read the comments please

function camelize(str){
    //Here try to fidn the position of the - character in the string
    //It must return an integer ( the position ) or -1 if there isn't exist
    let pos = str.indexOf('-');
    //We are creating a variable whre we'll build our new string
    let newStr = '';
    //Here we checking if the position finded
    if( pos >-1) {
        //Here we using the substring method ofg the javascript
        //which cutting the part of the string from 0 (index) to pos (index)
        //and assigning to newStr 
        //If everything are fine we have "background"
        newStr = str.substr(0,pos);
        //Here are checking if the length of the string is greater then the - char's position
        //and if si greater we can search the next part
        //Maybe the string is "background-" <-- We won't do anything
        if(str.length > pos+1 ) {
            //Here we adding from the part after the - char 
            //the first character but previously we using
            //the toUpperCase method to make it uppercase
            //If everything are fine we will have "backgroundC"
            newStr += str[pos+1].toUpperCase();
            //Finally we trying to add remained characters
            newStr += str.substr(pos+2);
         }
    }
    else {
        //We return the same string if there isn't a - character
        newStr = str;
    }
    return newStr;
}

Thx again. U didn’t have to do all that.

You’re welcome @hmahad
I can help as I can other people.