I'm writing a program in which the user inputs the components of multiple vectors (math). The number of vectors and number of components varies per user. The goal is to grab the components provided by the user and store them as a string array. I can change them into numbers later. My function looks like this:
//If numVect = 2, then this function should make ary1 = ["comp", "comp"] and ary2 = ["comp", "comp"]
function calcNewVect() {
//This stores the number of vectors the user has.
var numVect = document.getElementById("dimension").value;
//Goes through each of the input boxes and stores the value as a string.
for (i = 0; i < numVect; i++) {
var strVect = document.getElementById("vector_"+(i+1)).value;
//Trying to declare an array with a changing name here
var ary+i = strVect.split(", ");
}
}
I might be going about this wrong though.