JSFiddle - React, Tailwind, and code Playground

JavaScript

var str = "031p2";
alert(str.substring(0, str.length - 2));