Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

how to convert string to snake case in javascript

const snakeCase = (string) => {
  const toSnakeCase = (str = "") => {
    const strArr = str.split(" ");
    const snakeArr = strArr.reduce((acc, val) => {
      return acc.concat(val.toLowerCase());
    }, []);
    return snakeArr.join("_");
  };
  const newText = toSnakeCase(string);
  return newText
};
Source by www.textbotonline.com #
 
PREVIOUS NEXT
Tagged: #convert #string #snake #case #javascript
ADD COMMENT
Topic
Name
3+9 =