So konvertieren Sie die Zeichenfolge in JavaScript in Snake -Fall

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