Skip to content

Instantly share code, notes, and snippets.

@eivindingebrigtsen
Created May 30, 2011 11:51
Show Gist options
  • Save eivindingebrigtsen/998794 to your computer and use it in GitHub Desktop.
Save eivindingebrigtsen/998794 to your computer and use it in GitHub Desktop.
split
var txt = "Dette vil slette elevtelling og all tilhørende elevdata. Ønsker du å fortsette?";
function spliton30char (txt){
var arr = txt.split("");
var str = "";
var limit = 30;
var line = 0;
var ret = [];
for(var a in arr){
if(line<limit){
str += arr[a];
}else{
if(arr[a] === " "){
ret.push(str);
str = "";
line = 0;
}else{
str += arr[a];
}
}
line++;
}
ret.push(str);
return ret;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment