From 6872bab0de56f4c4bd26191cb7c12bc1fe0c3723 Mon Sep 17 00:00:00 2001 From: othman-19 <42877188+othman-19@users.noreply.github.com> Date: Thu, 7 Mar 2019 18:24:48 +0100 Subject: [PATCH] Update snakeCase.js hello; it will be a great honor to contribute in this exercise solution; 1. I think it is better to replace the "-" with a space " " in the beginning because that will create some mistakes when - come with an uppercase letter "-A" . 2. replace the "__" by "_" at the end because if ".." come with "-" or with uppercase will create two underscores. I hope this helps , thank you . --- snakeCase/snakeCase.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/snakeCase/snakeCase.js b/snakeCase/snakeCase.js index 4dc3af3..59f455e 100644 --- a/snakeCase/snakeCase.js +++ b/snakeCase/snakeCase.js @@ -1,6 +1,6 @@ const snakeCase = function(string) { // wtf case - string = string.replace(/\.\./g, " "); + string= string.replace(/[(\.\.)-]/g, " "); // this splits up camelcase IF there are no spaces in the word if (string.indexOf(" ") < 0) { @@ -13,7 +13,8 @@ const snakeCase = function(string) { .replace(/[,\?\.]/g, "") .replace(/\-/g, " ") .split(" ") - .join("_"); + .join("_") + .replace(/(__)/g,'_'); }; module.exports = snakeCase;