Find the number which is formed by the last n digits of the string where n = powerOf2
let i , number = 0 ; let len = str . length ; for ( i = len - powerOf2 ; i < len ; i ++ ) { number += ( str [ i ] - ' ' ) * Math . pow ( 10 , powerOf2 - 1 ) ; powerOf2 -- ; }