I am getting errors in JSlint and JSFiddle, however the scripts works perfectly.
I want to fix the errors, but I don't really know what to do.
The error I am getting is: 'allmonth is already defined'
The javascript (it's just a part of a full script, but here's the part with the errors)
$.each(data.product.variants, function (index, variant) {
var oldvartitle2 = variant.title,
oldvartitle = oldvartitle2.substring(oldvartitle2.indexOf(":") + 1),
newvartitle = oldvartitle.substr(3),
splitted = newvartitle.split(' '),
month2 = splitted[1];
if (month2 === 'januari') {
var allmonth = '01';
}
if (month2 === 'februari') {
var allmonth = '02';
}
if (month2 === 'maart') {
var allmonth = '03';
}
if (month2 === 'april') {
var allmonth = '04';
}
if (month2 === 'mei') {
var allmonth = '05';
}
if (month2 === 'juni') {
var allmonth = '06';
}
if (month2 === 'juli') {
var allmonth = '07';
}
if (month2 === 'augustus') {
var allmonth = '08';
}
if (month2 === 'september') {
var allmonth = '09';
}
if (month2 === 'oktober') {
var allmonth = '10';
}
if (month2 === 'november') {
var allmonth = '11';
}
if (month2 === 'december') {
var allmonth = '12';
}
var allmonths = splitted[0] + '/' + allmonth + '/' + splitted[2];
$('.multiple_' + index2 + '_variants .datacursusul_' + index2 + '_ul').append('<li class="' + allmonths + '">' + oldvartitle + '</li>');
});
I want to change the 'allmonth' variable to a number depending on what the month2 variable contains.
Thanks!
var allmonth;at the top of the scope, and then just useallmonth = '01'&tc for all the assignments.