How to use string.substr() function? May 31, 2023 by Tarik If I am correct, the second parameter of substr() should be the length of the substring. How about b = a.substr(i,2); ?