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

Posting Code

Markdown is supported in the comment area, so you can write inline code in backticks like `this` or multiline blocks of code in in triple backtick fences like this:

<div>Example code</div>

You don't need to escape code in backticks, Markdown does that for you. If anything screws up, contact us and we can fix it up for you.

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