Advertisement
Goufix

Untitled

Apr 18th, 2019
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function toSneakCase(string) {
  2.   let result = ''
  3.   string.split('')
  4.   .forEach((value, i) => {
  5.     if(!value.search(/[A-Z]/) && !!i &&
  6.     result[result.lenght -1].search(/[a-z]/)) {
  7.       result += `_${value.toLowerCase()}`;
  8.     } else {
  9.       result += value.toLowerCase()
  10.     }
  11.   })
  12.   return result
  13. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement