trim examples c2 b6

Solutions on MaxInterview for trim examples c2 b6 by the best coders in the world

showing results for - "trim examples c2 b6"
Luka
18 Jun 2016
1//The general syntax for this method is:
2
3stringName.trim();
4/*This method returns a copy of the string with any leading or trailing
5whitespace removed. Whitespace characters are those that do not 
6display anything on the screen, such as spaces and tabs.*/
7
8console.log("Saint Louis ".trim());
9console.log(" Saint Louis".trim());
10console.log(" Saint Louis ".trim());
11
12//Saint Louis
13//Saint Louis
14//Saint Louis
15
16
17/*When typing an email address into a web site, a user may inadvertently
18type a space before and/or after the email address. We can clean up 
19such input using the trim method.*/
20
21//This example cleans up user input with trim.
22
23let input = " fake.email@launchcode.org ";
24let email = input.trim();
25console.log(email);
26
27//fake.email@launchcode.org