Error Unexpected token for [closed]

2

I'm having trouble applying a for to fullcalender to list events in a calendar. It gives me the following error:

  

Unexpected token for

Here is my code:

for (i = 0; i< array1.length; i++) {
    {
        title: array5[i],
        start: array1[i]+'T'+array3[i],
        end:  array2[i]+'T'+array4[i]'
    },  
}

I've already removed for to see if the problem was array and it worked, what can I be doing wrong?

    
asked by anonymous 22.06.2015 / 01:00

2 answers

3

You need to put this object somewhere:

{
    title: array5[i],
    start: array1[i]+'T'+array3[i],
    end:  array2[i]+'T'+array4[i]'
}

For example:

var objs = []

for (i = 0; i< array1.length; i++) {
    objs.push({
        title: array5[i],
        start: array1[i]+'T'+array3[i],
        end:  array2[i]+'T'+array4[i]'
    })
}
    
22.06.2015 / 01:13
4

What the @Jair said is correct, just to complement, you created an object that is not added nowhere and added a comma in the end without purpose, it makes me think you still need some knowledge / domain about javascript.

I recommend you read:

I believe the use is this (read the comments in the code):

var eventos = [];//Cria um array na variavel eventos

for (var i = 0; i< array1.length; i++) {
    //Adiciona o evento ao array
    eventos.push({
        title: array5[i],
        start: array1[i]+'T'+array3[i],
        end:  array2[i]+'T'+array4[i]'
    });
}

$('#calendar').fullCalendar({
    header: {
        left: 'prev,next today',
        center: 'title',
        right: 'month,basicWeek,basicDay'
    },
    defaultDate: '2015-02-12',
    editable: true,
    eventLimit: true,
    events: eventos //Adiciona os eventos ao fullCalendar
});
    
22.06.2015 / 01:38