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

  • Use Markdown, and it will escape the code for you, like `<div class="cool">`.
  • Use triple-backticks for blocks of code.
      <h1>multi-line block of code</h1>
      <span>be cool yo.</span>
  • Otherwise, escape your code, like <code>&lt;div class="cool"&gt;</code>. Markdown is just easier though.

Current ye@r *

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