Reputation: 955
I've been working with some arrays in javascript. I've got a parse error at this line:
var cardData[0] = [
[
'Rumble Pack',
'Robert Mugabe',
0.2,
0.7,
21,
RuleTypes.dictatorship,
'88%',
'45%',
'\'The Jewel of Africa\', Zimbabwe, returning to the stone age. R.M. let a rabble led by Chenjerai \'Hitler\' Hunzwi murder white farmers at will. 25 % of Zimbabwians HIV-positive. Life expectancy fallen 16 yrs. under R.M.'
]
];
Remember that the line is a single line, i don't know if that makes any difference... Can someone help me? :) .
Upvotes: 1
Views: 214
Reputation: 911
You can't assign the value (in your case array) to the first element of array before creating the array first. You can try to change it to:
var cardData = [];
cardData[0] = [
[
'Rumble Pack',
'Robert Mugabe',
0.2,
0.7,
21,
RuleTypes.dictatorship,
'88%',
'45%',
'\'The Jewel of Africa\', Zimbabwe, returning to the stone age. R.M. let a rabble led by Chenjerai \'Hitler\' Hunzwi murder white farmers at will. 25 % of Zimbabwians HIV-positive. Life expectancy fallen 16 yrs. under R.M.'
]];
Also RuleTypes
element has to be defined somewhere in your code.
Upvotes: 2
Reputation: 187242
var cardData[0]
doesn't work like that. Do this instead:
var cardData = [];
cardData[0] = stuff;
or more simply:
var cardData = [stuff];
var
declares a variable with a certain name, and bracket notation is not a valid in a variable name.
Upvotes: 6