Vanarajan Vanarajan - 6 months ago 51
jQuery Question

How to trim the string using node.js?

I am trying to trim the string. I google it for trim.

The tips i am getting.

  1. name.trim(); -- Not recognized trim() function

  2. npm install --save string

    var S = require('string');
    S('hello ').trim().s; -- this also same issue

Can you any one assist me what is the problem of the above method or anything i have missed it?


You don't need jquery for this...

var str = "       Hello World!        ";
var trimmedStr = str.trim();

This will output the following in the console:

"Hello World!"