Just try to ask them to input their numbers or grade, separated by a comma and then you can split on it.

var arr = prompt("Enter your numbers").split(",")

Or, ask prompt ten times

var arr = [];
for(var i = 0; i < 10; i++)
   arr.push(prompt("Enter a number");

If you want them to be numbers, just prefix prompt with +, so it becomes a number(provided they're actual numbers) or just do

arr = arr.map(Number);
Answer from Amit Joki on Stack Overflow
๐ŸŒ
SheCodes
shecodes.io โ€บ athena โ€บ 45475-how-to-create-a-prompt-for-an-array-in-javascript
[JavaScript] - How to create a prompt for an array in | SheCodes
Learn how to use the prompt and split methods in JavaScript to create an array from user input. ... How do I make a javascript event where you click on a thumbnail image and it pops up with a full sized image? JavaScript event handling image pop-up thumbnail DOM manipulation ... Is my JS code ...
Discussions

Adding User Input to the Array in JavaScript
Zvonimir Perkovic is having issues with: Hi everyone, Here is the problem I'm struggling with: Ask the user how many students are in the class with a prompt.... More on teamtreehouse.com
๐ŸŒ teamtreehouse.com
2
October 1, 2016
How to save prompt input into array
I`m having some issue with Javascript. We just started to study it a couple weeks ago and I have to do a work for class: Need to do a prompt. get 10 numbers input (10 grades) from the user. put the More on stackoverflow.com
๐ŸŒ stackoverflow.com
May 22, 2017
How to create an array from names input through prompt?
Prompt engineering is the application ... of prompts - i.e., inputs into generative models like GPT or Midjourney. ... A community dedicated to all things web development: both front-end and back-end. For more design-related questions, try /r/web_design. ... This subreddit is for anyone who wants to learn JavaScript or help others do so. Questions and posts about frontend development in general are welcome, as are all posts pertaining to JavaScript on the backend. ... Unofficial Node.js ... More on reddit.com
๐ŸŒ r/learnjavascript
2
2
March 1, 2023
Js Array Prompt Input Data - JavaScript
I am playing about with javascript arrays. Have recently just sat today looking through w3c and going through pages in a w3c book i bought on javascript and ajex and i was wondering whether you guys can help me on this little thing im playing on. someone suggested if im wanting to display stuff ... More on sitepoint.com
๐ŸŒ sitepoint.com
0
November 16, 2011
๐ŸŒ
Codecademy
codecademy.com โ€บ forum_questions โ€บ 520ac81bf10c6030ad000e07
Prompts as information to put in an array. | Codecademy
var first_name = prompt(please enter your first name.) ... Doing this for the rest of the personโ€™s attributes, it would take the information entered and then list them in the contacts array which could then be listed, searched by, etc.
๐ŸŒ
Team Treehouse
teamtreehouse.com โ€บ community โ€บ adding-user-input-to-the-array-in-javascript
Adding User Input to the Array in JavaScript (Example) | Treehouse Community
October 1, 2016 - Output the list of student names to the screen by looping through the new array of student names. I would appreciate any hint for the steps 2 & 3. ... As always, Steven Parker has provided a great answer. I have opted for an alternate approach using 'recursion'. Explanation below. const readline = require('readline') const rl = readline.createInterface({ input: process.stdin, output: process.stdout, prompt: ':' }) let numberOfStudents let studentsNames = [] // Helper functions function isNumeric(n) { return !isNaN(parseFloat(n)) && isFinite(n) } function ordinalSuffixOf(i) { var j = i % 10, k
๐ŸŒ
Reddit
reddit.com โ€บ r/learnjavascript โ€บ how to create an array from names input through prompt?
r/learnjavascript on Reddit: How to create an array from names input through prompt?
March 1, 2023 - I am trying to develop a C++ program that creates a text menu which allows the user to choose how to input data into an array (keyboard or from a text file). How do I limit the array size to 100? ... Prompt engineering is the application of engineering practices to the development of prompts - i.e., inputs into generative models like GPT or Midjourney.
๐ŸŒ
EDUCBA
educba.com โ€บ home โ€บ software development โ€บ software development tutorials โ€บ javascript tutorial โ€บ javascript prompt
JavaScript prompt | How does prompt pop up work in JavaScript?
June 22, 2023 - <!DOCTYPE html> <html> <body> <font color="green"> <h1 align="center">Displaying User Input</h1> </font> <script> function getMyArray() { var userInputArray=[]; for(let i=0;i<=9;i++) { userInputArray.push(prompt("enter array index "+(i+1)+" value","1")); } document.write("User input is Array values are =>") for(let i=0;i<=9;i++) { document.write(userInputArray[i]+"<br>"); } } getMyArray(); </script> </body> </html>
Call ย  +917738666252
Address ย  Unit no. 202, Jay Antariksh Bldg, Makwana Road, Marol, Andheri (East),, 400059, Mumbai
๐ŸŒ
SitePoint
sitepoint.com โ€บ javascript
Js Array Prompt Input Data - JavaScript
November 16, 2011 - I am playing about with javascript arrays. Have recently just sat today looking through w3c and going through pages in a w3c book i bought on javascript and ajex and i was wondering whether you guys can help me on this little thing im playing on. someone suggested if im wanting to display stuff to use a drop down box but i need to learn to use arrays as the course im studying in college is on javascript and i feel this would be beneficial for me personally to know. i want to know if its possib...
Find elsewhere
๐ŸŒ
W3Schools
w3schools.com โ€บ jsref โ€บ met_win_prompt.asp
Window prompt() Method
add() compare() equals() from() getTimeZonetransition() new() round() since() startofday() subtract() toInstant() toJSON() toLocaleString() toPlainDate() toPlainDateTime() toPlainTime() toString() until() valueOf() with() withCalendar() withPlainTime() withTimeZone() JS Typed Arrays
๐ŸŒ
WebDeveloper.com
webdeveloper.com โ€บ community โ€บ 297613-how-to-store-prompt-inputs-in-an-array-and-then-print-that-data-out
How to store prompt inputs in an array and then print that data out
Also, document.write of an array 'blind' like that is probably going to look pretty ugly, you'd want to at least throw some line-breaks in there by iterating through the array. (function() { <i> </i>var results = [], answer, i; <i> </i>while ((answer = prompt('Geef een getal in!')) &gt; 0) results.push(answer); <i> </i>for (i = 0; i &lt; results.length; i++) document.write(results[i] + '&lt;br /&gt;'); })(); Is probably more along the lines of what you are trying to do.
๐ŸŒ
SitePoint
sitepoint.com โ€บ javascript
Need help with an prompt to array in a while loop - JavaScript
March 7, 2010 - myResponse = ''; do { if (myResponse > '') { loopCounter++; names[loopCounter] = myResponse; } myResponse = prompt("What's your favorite Lord of the Rings Character?\ \\rtype 'exit' to leave prompting",""); } while (myResponse !== 'exit'); ... ok i figured most of it out now but now im wondering how do i ignore data or keep information someone has entered from entering the array.
๐ŸŒ
IncludeHelp
includehelp.com โ€บ code-snippets โ€บ create-a-user-defined-array-in-javascript.aspx
Create a user defined array in JavaScript
October 17, 2017 - For our purpose, we are going to use this function and get the input from the user and store it inside the variable. ... var inputArray = []; var size = 5; //Maximum Array size for(var i=0; i<size; i++) { //Taking Input from user inputArray[i] = prompt('Enter Element ' + (i+1)); } //Print the ...
๐ŸŒ
JavaScript.info
javascript.info โ€บ tutorial โ€บ the javascript language โ€บ data types
Arrays
The array has 3 values: initially it had two, plus the function. ... Asks the user for values using prompt and stores the values in the array.
๐ŸŒ
Stack Overflow
stackoverflow.com โ€บ questions โ€บ 15559947 โ€บ using-an-array-function-inside-a-prompt
Using an array function inside a prompt
var theArray = []; for (var i = 0; i < 3; i++) { var plusOne = i + 1; theArray[i] = prompt("Please enter threee names: ", "Name " + plusOne); document.getElementById("msg" + plusOne).innerHTML = theArray[i]; } Once your names are in an array, it will be trivial to sort them:
๐ŸŒ
Teachics
teachics.org โ€บ home โ€บ javascript examples โ€บ javascript program to read values using prompt popup box
JavaScript program to read values using prompt popup box | JavaScript Examples | Teachics
June 4, 2024 - <html> <body> <script> var n = window.prompt("Enter size of the array"); var arr = new Array(); var sum = 0; for (let i = 1; i <= n; i++) { arr[i] = parseInt(window.prompt("Enter element " + i)); sum = sum + arr[i]; } alert("Sum =" + sum); </script> </body> </html>
๐ŸŒ
Stack Overflow
stackoverflow.com โ€บ questions โ€บ 64254758 โ€บ how-to-make-an-array-from-prompt-input-data
How to make an array from prompt input data? [duplicate]
var number = parseInt( window.prompt("How many temperatures would you like to average?")); for (var i = 0; i < number; i++) { window.prompt("Enter temperature") } var temps = new Array(number[i]); for (var j = 0; j < temps.length; j++); { ...
Top answer
1 of 2
1

So, I think the problem is that it's creating callbacks and the loop continues on so you're getting weird results. Using a variant of the Tiny CLI example, you can create a prompt with a question from the array and watch the line event to get the input, then repeat. Here's a quick example.

var read = require('readline'),
    input = read.createInterface(process.stdin, process.stdout),
    questions = ['test1: ', 'test2: '],
    counter = 0;

input.setPrompt(questions[0]);
input.prompt();

input.on('line', function (a) {
    console.log('answer: ', a);
    counter++;
    if (counter < questions.length) {
        input.setPrompt(questions[counter]);
        input.prompt();
    } else {
        process.exit(0);
    }
});
2 of 2
0

I wrote some utility methods to help with this. Couple of added gems in here like it automatically writes the last values entered to a hidden file so a user can press enter

```

var async = require('async');
var fileUtils = require('../util/file-util');

var LAST_OPTIONS_FILE='./.last-options-file';


/**
 * The prompt object type that is used by askSeries
 * @typedef {Object} Prompt
 * @property {string}  key - is used as the variable name
 * @property {string}  [default] - is a default value so you can just press enter
 * @property {string}  [format] - validates input against a regex
 * @property {string}  [question] - use to make a more human readable prompt
 * @property {boolean} [confirm] - will force user to confirm the value if it was found on the command line
 * @property {boolean} [forceEnter] - if true, user must enter this value (last value is ignored)
 */


/**
 * Asks user for input for each of the prompts
 *
 * <PRE>
 * Example:
 * askSeries([{key:"customerId"}, {key:"subscriptionId", "default":"blah"}], function(inputs) {
 *    console.log(inputs);
 * });
 * OUTPUT:
 *   customerId: 5
 *   subscriptionId [blah]: 9
 *   [ customerId: '5', subscriptionId: '9' ]
 *
 * askSeries([{key:"customerId", question:"Enter Customer Id", format: /\d+/}, {key:"subscriptionId", "default":"blah"}], function(inputs) {
 *    console.log(inputs);
 * });
 * OUTPUT:
 *   Enter Customer Id: abc
 *   It should match: /\d+/
 *   Enter Customer Id: 123
 *   subscriptionId [blah]:
 *   [ customerId: '123', subscriptionId: 'blah' ]
 * </PRE>
 *
 * @param {Prompt[]} prompts - an array of Prompts which dictate what user should be asked
 * @param {object} [argv] - if any of prompts .keys match argv it sets the default appropriately,
 *                          argv will get all prompt .key values set on it as well
 * @param {function} callback - signature is function(err,params)
 */
exports.askSeries = function(prompts,argv,callback) {
    var input = {};
    var lastVal = {};
    if(typeof argv === 'function') { callback = argv; argv=null; }

    lastVal = fileUtils.readJSONFileSync(LAST_OPTIONS_FILE);
    if( !lastVal ) { lastVal = {}; }

    console.log("LASTVAL", lastVal);


    async.eachSeries(prompts, function(prompt, next) {
        if( !prompt.key ) { callback(new Error("prompt doesn't have required 'key' param")); }
        if( !prompt.confirm && argv && argv[prompt.key] ) {
            input[prompt.key] = argv[prompt.key];
            return next();
        }
        else {

            var defaultVal = prompt.default;
            if( argv && argv[prompt.key] ) { defaultVal = argv[prompt.key]; }
            else if( !prompt.forceEnter && lastVal[prompt.key] ) { defaultVal = lastVal[prompt.key]; }

            exports.ask( prompt.question || prompt.key, prompt.format || /.+|/, defaultVal, function(value) {
                if( !value ) {
                    if( prompt.default ) {
                        value = prompt.default;
                    }
                    if( argv && argv[prompt.key] ) {
                        value = argv[prompt.key];
                    }
                }
                input[prompt.key] = value;
                if( argv ) { argv[key] = value;}
                next();
            });
        }
    }, function(err) {
        try {
            var fileData = JSON.stringify(input);
            fileUtils.writeToFile(LAST_OPTIONS_FILE, fileData );
        }catch(err) { console.log("Unable to save entered values"); }
        callback(err,input);
    });
};

/**
 * Prompts user for input
 *
 * @param {string} question prompt that is displayed to the user
 * @param {string} [format] regex used to validate
 * @param {string} [defaultVal] uses this value if enter is pressed
 * @param callback is invoked with value input as callback(value);
 */
exports.ask = function ask(question, format, defaultVal, callback) {
    var stdin = process.stdin, stdout = process.stdout;

    if( typeof(format) === 'function' ) {
        callback = format;
        format = null;
    }
    if( typeof(defaultVal) === 'function') {
        callback = defaultVal;
        defaultVal = null;
    }

    stdin.resume();

    var prompt = question;
    if( defaultVal ) {
        prompt += " [" + defaultVal + "]";
    }
    prompt += ": ";

    stdout.write(prompt);

    stdin.once('data', function(data) {
        data = data.toString().trim();

        if( !data && defaultVal ) {
            data = defaultVal;
        }

        if (!format || format.test(data)) {
            callback(data);
        } else {
            stdout.write("It should match: "+ format +"\n");
            ask(question, format, callback);
        }
    });
};

/**
 * Prints the usage from the <link Prompt> array.
 * @param {Prompt[]} prompts - the array of prompts that will be asked if not entered on cmd line.
 * @param {string} binaryName - if specified it puts it in the usage as <binaryName> [options]
 * @param {boolean} [dontPrint] - if true, the usage will not be written to console
 */
exports.getUsage = function(prompts, binaryName, dontPrint) {
    if(!binaryName) { binaryName = "program_name";}
    var s = "\nUsage: \n./" + binaryName + " [options]\n\n options:\n";

    console.log(prompts);
    prompts.forEach( function(p) {
        s += "   --" + p.key;
        if(p.question) { s += ": " + p.question;}
        if(p.format) { s += ", format: " + p.format; }
        s += "\n";
    });

    if( !dontPrint ) {
        console.log( s );
    }

    return s;
};fs

```