programming-examples/js/String/Remove a specific number of characters from a string.js

7 lines
214 B
JavaScript
Raw Normal View History

2019-11-15 12:59:38 +01:00
truncate_string = function (str1, length) {
if ((str1.constructor === String) && (length>0)) {
return str1.slice(0, length);
}
};
console.log(truncate_string("Robin Singh",4));