js remove the last character of a string
const text = 'abcdef'
const editedText = text.slice(0, -1) //'abcde'
js remove the last character of a string
const text = 'abcdef'
const editedText = text.slice(0, -1) //'abcde'
remove the last character from a string in JavaScript,
let str = 'Masteringjs.ioF';
str.slice(0,-1); // Masteringjs.io
str.substring(0, str.length - 1); // Masteringjs.io
str.substr(0, str.length - 1); // Masteringjs.io
str.replace(/.$/, ''); // Masteringjs.io
// For a number, use \d$.
let str = 'Masteringjs.io0';
str.replace(/\d$/, ''); // Masteringjs.io
// advanced features
let str2 = 'Masteringjs.io0F';
// If the last character is not a number, it will not replace.
str.replace(/\d$/, ''); // Masteringjs.io0F;
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us