CSE 154 Examples

Trimming Strings

Description :

In Javascript, you can use the trim() method to remove extra whitespace from both sides of a string. The original string is unchanged.

Syntax : let length = original_string.trim();

Examples :

				 
           let str = "       Hello World!        ";
           let changed = str.trim();
				 
           changed =  ?? 
       
				 
           let str = "Hello World!        ";
           let changed = str.trim();
				 
           changed =  ??