camel to snake case converter javascript code example

Example: how to convert snake case to camel snake case javascript typescript

function convertSnakeToCamelSnake(obj: any){
  let newTokens = []
  if (obj) {
    Object.keys(obj).forEach( key => {
      newTokens = []                                                                // Reset each loop
      let tokens = key.split('_')
      tokens.forEach( token => { newTokens.push(capitalizeFirstLetter(token)) });   // Capitalize first letter of each token
      newTokens.join('')                                                            // Concatenate array indexes to string
    });
  }else{
    console.log("Can not convert case of object:" + obj)
  }
  return newTokens
}