I'm trying to use Regex with my assignment.
2 problems here I can't solve:
problem 1: The 1st if the statement is meant to put the string into "pascal" case. The 2nd if statement into "camel" case. Regardless the statement it looks like executions stops after 1st statement. What do I do wrong here?
problem 2: My 1st if statement even though return result ("pascal") i can not figure out how to get rid of white spaces in my regex part of the code.
Please help. stuck 2nd day in a row.
const makeCase = function(input, type) {
//place your code here
let inType = type;
let finalInput = (type === inType)
if(finalInput) {
return input.replace(/^(.)|\s+(.)/g, function(str){
return str.toUpperCase();
});
} else if(finalInput) {
return input.replace(/\W+(.)/g, function(str){
return str.toUpperCase();
});
}
};
console.log(makeCase("this is a string", "pascal"));
console.log(makeCase("this is a string", "camel"));