Search
 
SCRIPT & CODE EXAMPLE
 

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
};
Comment

PREVIOUS NEXT
Code Example
Javascript :: async await promise all javascript 
Javascript :: how to get last element of array in javascript 
Javascript :: Check for a Null or Empty String in JavaScript 
Javascript :: connect ECONNREFUSED 127.0.0.1:80 nuxt config 
Javascript :: react-dom and babel cdn 
Javascript :: how to get all attributes of an element in jquery 
Javascript :: javascript date format 
Javascript :: javascript global object 
Javascript :: moment get month short name 
Javascript :: convert jquery to string 
Javascript :: javascript combine objects 
Javascript :: js concat string 
Javascript :: crud template 
Javascript :: Environment key "jest/globals" is unknown - react 
Javascript :: get ini file with node js 
Javascript :: compare two arrays and remove duplicates javascript 
Javascript :: javascript to change value on screen with radio button 
Javascript :: multiple checkbox validation in jquery 
Javascript :: firefox freeze page 
Javascript :: javascript get fibonacci number 
Javascript :: fivem esx script 
Javascript :: DataTables warning: table id=example-dt - Invalid JSON response. 
Javascript :: how to convert string into binary in javascript 
Javascript :: javascript slider get value react 
Javascript :: javascript object get value by key in array 
Javascript :: jwt expiresin 
Javascript :: axios api post request 
Javascript :: json_decode javascript 
Javascript :: int val javascript 
Javascript :: express reload page after post 
ADD CONTENT
Topic
Content
Source link
Name
1+5 =