Question: * Problem 1: replace all internal whitespace in a string value with underscore * ('_'), and makes it lowercase. * * We want to be
* Problem 1: replace all internal whitespace in a string value with underscore
* ('_'), and makes it lowercase.
*
* We want to be able to convert a string to Lower Snake Case style, so that all
* leading/trailing whitespace is removed, and any internal spaces, tabs, or dots,
* are converted to '_' and all letters are lower cased.
*
* The snake() function should work like this:
*
* snake('abc') --> returns 'abc'
* snake(' ABC ') --> returns 'abc'
* snake('ABC') --> returns 'abc'
* snake('A BC') --> returns 'a_bc'
* snake(' A bC ') --> returns 'a-bc'
* snake('A BC') --> returns 'a_bc'
* snake('A.BC') --> returns 'a_bc'
* snake(' A.. B C ') --> returns 'a_b_c'
*
* @param {string} value - a string to be converted
* @return {string}
******************************************************************************/
function snake(value) {
// Replace this comment with your code...
return value;
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
