how to get first two digits of a string in javascript code example
Example 1: get first 3 digit from string js
const string = "0123456789";
console.log(string.slice(0, 2)); // "01"
console.log(string.slice(0, 8)); // "01234567"
console.log(string.slice(3, 7)); // "3456"
Example 2: get first 2 digits of number javascript
const trial = "19.0.0.1"
console.log(trial.split(".").slice(0, 2).join("."))
// 19.0