C
css-discuss.org
I have a syntax error on the first string += line.
I don't know if the line is even right. Do I need an inner for loop
to compare the letter with the next letter and the next letter after
it?
The problem is to insert a <span> tag between letters where there are
3 of the same letters, otherwise just add the character to the
string. The return result should be:
a b c c d <span> e e
e </span> e e f' e f e
f <span> a a a <span> f f f'</span>
<script type="text/javascript">
var array = ['a', 'b', 'c', 'c', 'd','e', 'e',
'e', 'e', 'e', 'f', 'e', 'f', 'e',
'f', 'a', 'a', 'a', 'f', 'f', 'f'];
function myfunc(arr) {
var string = '';
for (var i= 0; i< arr.length ; i++){
if (arr == arr[i+1] && arr == arr[i+2])
{
string += " '<span>' + arr + arr[i+1] + arr[i+2] + '</span>'
";
I don't know if the line is even right. Do I need an inner for loop
to compare the letter with the next letter and the next letter after
it?
The problem is to insert a <span> tag between letters where there are
3 of the same letters, otherwise just add the character to the
string. The return result should be:
a b c c d <span> e e
e </span> e e f' e f e
f <span> a a a <span> f f f'</span>
<script type="text/javascript">
var array = ['a', 'b', 'c', 'c', 'd','e', 'e',
'e', 'e', 'e', 'f', 'e', 'f', 'e',
'f', 'a', 'a', 'a', 'f', 'f', 'f'];
function myfunc(arr) {
var string = '';
for (var i= 0; i< arr.length ; i++){
if (arr == arr[i+1] && arr == arr[i+2])
{
string += " '<span>' + arr + arr[i+1] + arr[i+2] + '</span>'
";