I need to create a 2D array for some POC work.
The first value of the array needs to go up in single increments between the values 1 to 1000 and the second value needs to be a random number from values 1 to 50.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
To explain how we end up with a random number between 1 and 50:
Math.random()generates a random floating point numberrwhere 0 ≤r< 1. Thus, multiplying that by 50 will result in a numberswhere 0 ≤s< 50. Then we useMath.floor(), which rounds a decimal down to the nearest integer (so the result will be an integer between 0 and 49 inclusive). Adding 1 to that will give the desired result — a random integer between 1 and 50.