Answer the question
In order to leave comments, you need to log in
How to pass multiple parameters to split() to split?
You need to make a function that translates the received string into camel-case. That is, so that "bgColor" is obtained from "bg-color". I did like this:
function toCamelCase(str){
return str.split(' ' || '-' || '_').reduce((sum, cur) =>
{return sum + cur.charAt(0).toUpperCase + cur.substr(1)})
}
Answer the question
In order to leave comments, you need to log in
str.split(/[ _-]/g);
The separator parameter can be either a string or a regular expression
Plus you need to add parentheses to call toUpperCase()
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question