Basically if you are searching "whole logic" to convert string to int then you have to find ASCII code for each alphabet in string and then convert it to integer and make sum of all 48 to 57 are ASCII codes are for number 0 to 1. Below is example code
let parseINT = (b) => b.split("").map((e,i) => {
let value = e.charCodeAt(0) - 48;
return value * [...Array(((i - b.length) * -1)).keys()].reduce((a, b) => a > 0 ? (a * 10) : 1, 0);
}).reduce((a, b) => a + b, 0)
or short form will be like
let parseINT = (b) => b.split("").map((e,i) => ((e.charCodeAt(0) <= 57 ? e.charCodeAt(0) : 48) - 48) * [...Array(((i - b.length) * -1)).keys()].reduce((a, b) => a > 0 ? (a * 10) : 1, 0)).reduce((a, b) => a + b, 0);