Grow your CSS skills. Land your dream job.

Last updated on:

Remove the Last Character from a String

var origString = 'Happy Dance7';
var trimmedString = origString.substring(0, origString.length-1);
// 'Happy Dance'


  1. There’s a way shorter way :-)

    "Happy Dance7".slice(0,-1) //"Happy Dance"
  2. Permalink to comment#

    Or, you could use slice();

    var origString = ‘Happy Dance7′;
    var trimmedString = origString.slice(0,-1);

  3. Permalink to comment#

    Shorter code is better. Thanks to jQuery.

Leave a Comment

Current day month ye@r *

*May or may not contain any actual "CSS" or "Tricks".