javascript - split string in two on given index and return both parts -


i have string need split on given index , return both parts, seperated comma. example:

string: 8211 = 8,211         98700 = 98,700 

so need able split string on given index , return both halves of string. built in methods seem perform split return 1 part of split.

string.slice return extracted part of string. string.split allows split on character not index string.substring need returns substring string.substr similar - still returns substring

try

function splitvalue(value, index) {      return value.substring(0, index) + "," + value.substring(index);  }    console.log(splitvalue("3123124", 2));


Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -