Answers for "js get input array"

1

take array input

arr = list(map(int, input().split()))
Posted by: Guest on August-08-2020
0

how to take array input from user in javascript

// Here we define a array variable to store user input values:
		var arr=[]; 
	/* Then we define a while loop for taking multiple values.
	it takes the value and store the values into an array until 
    the condition is true.But when a user didn't give a value 
    or just give 'q'value short for quit then it breaks the loop 
    and logs  the array into a console interface of webpage.*/
		while(true){  
			var input=prompt("Enter the Numbers: ");
			if(input== null || input== 'q')
			{
				break;
			}
			arr.push(Number(input));
		}
		console.log(arr);
Posted by: Guest on August-03-2021

Python Answers by Framework

Browse Popular Code Answers by Language