Computer scienceProgramming languagesJavaScriptWorking with dataStrings

String transforming

Prepare data

Report a typo

You have a test form and need to tidy up the input. For example, "Sample" and "sample " should be considered equivalent.

Return a string with any extra spaces deleted and the letters converted to lowercase.

Sample Input 1:

Test   

Sample Output 1:

test

Sample Input 2:

 test 

Sample Output 2:

test

Sample Input 3:

  TEST

Sample Output 3:

test
Write a program in JavaScript
function prepareData(line) {
//write your code here
}
___

Create a free account to access the full topic