Currently im writing a program that calculates the standard deviation of the numbers the user has inserted into the input box. I know I can use .substring(#,#) to find the value between the two numbers in a string, and .includes() to find if the string has that corresponding value indicated, but how do I find multiple values within a user input and pair them into variables? For example this is the user's input (respresenting a row on a data graph); "1, 20, 3, 500, 8"
When they write the first, second, third, etc. numbers in their input, I want each number to be assigned to a variable or list or something. I also want the user to be able to write up to 5 characters in their number (99,999 max) but I wont know how many numbers they'll use. I've been stuck on this for a bit so any advice would help
I tried doing
function charDefine() {
firstNum = problem.substring(0,2);
secondNum = problem.substring(5,7);
thirdNum = problem.substring(10,12);
fourthNum = problem.substring(15,17);
fifthNum = problem.substring(20,22);
sixthNum = problem.substring(25,27);
seventhNum = problem.substring(30,32);
}
It resulted in a working program (there's other lines in which they call this function but those are irrelevant) with very limited access to freedom to numbers
firstNum, secondNum, thirdNum, etc. indicates the order of numbers the user inputed but I want the user to have as many numbers as they want so I cant keep writing lines until like onehundredthNum. Also each substring only allows each number to be 2-digit with a space and comma in between each value.