How to remove last character from string value?

How to remove last character from string value?

const val = "11.125"; 

const result = val.slice(0, -1);

Or

const result = val.substring(0, val.length - 1);

Only if we need numeric value and ristrict decimal value two digit for above case 


let numb = parseFloat(val); numb = numb.toFixed(2);

Comments

Popular posts from this blog

world tourism guide Template

Es6 how to check if value is not null or undefined?