forked from ygs-code/vue
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsplit.html
35 lines (32 loc) · 926 Bytes
/
split.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
<script>
var arrStr=['st ig ood shit gonging good shit gonging good' ,'play admin office friend,quick ready thank yellow'];
arrStr = arrStr.map(item=>{
var itemArrStr = item.split(' ');
let length = 0;
let str = ''
for(let index=0;index<itemArrStr.length;index++){
length+=itemArrStr[index].length+1;
if(length>15){
length=0;
str +='<br/>'+itemArrStr[index]+' ';
}else{
str +=itemArrStr[index]+' ';
}
}
length=length-1;
console.log(length);
console.log(str);
return str
})
console.log('st ig ood shit'.length)
console.log(arrStr)
</script>
</body>
</html>