I have a multidimensional array named "notes". It has the fields "note1", "note2", and "note3".
I have a variable named "noteNum" that can be set to 1, 2, or 3.
If "noteNum = 2", then "notes[0].note + noteNum" should be equal to "notes[0].note2". BUT I can't seem to attach the variable? Why not?
My code is below:
// Array constructor
function notesConstructor(note1, note2, note3) {
this.note1 = note1;
this.note2 = note2;
this.note3 = note3;
}
var notes = new Array();
notes[0] = new notesConstructor("Note 1A example note", "Note 2A example note", "Note 3A example note");
notes[1] = new notesConstructor("Note 1B example note", "Note 2B example note", "Note 3B example note");
console.log(notes[0].note1); // "Note 1A example note"
// WHERE THE PROBLEM IS...
var noteNum = 2;
console.log(notes[0].note + noteNum); // This SHOULD be "Note 2A example note" but it doesn't work
Fiddle: http://jsfiddle.net/baUaL/