Question
JavaScript Related question. 1st step, Write a JavaScript program that Takes an integer as input, such as Y Displays (or Returns) a two-dimensional array (YxY)
JavaScript Related question.
1st step, Write a JavaScript program that Takes an integer as input, such as Y Displays (or Returns) a two-dimensional array (YxY) as follows (with Y=4):
1 | 2 | 3 | 4 |
12 | 13 | 14 | 5 |
11 | 16 | 15 | 6 |
10 | 9 | 8 | 7 |
For output, you can either simply write the resulting matrix to the console, or better show an html table in a browser.
2nd step, Convert final Spiral Matrix nodeJS app.
Starting Point. Convert the JS spiral matrix to run under nodeJS app and outputs the outcome using console.log.
You should have done it.
Step 1. Execute your spiral matrix solution in nodeJS directly (outside of VSC) and make sure output via console.log() is correct.
Step 2. Convert the JS spiral matrix to run under nodeJS app and outputs the outcome to a browser (via returned html).
Step 3. To continue enhance No.2 above by creating a URL (such as http://localhost/matrix/4). When it is entered into a browser, your nodeJS app will return the result matrix with the given dimension in the browser.
Step 4: Complete HTML Form:
Create a UI page with 3 elements:
___________. ___________
please enter dimension: |___________| |__submit___|
____________________________________________.
| |
| |
| |
| Matrix shows up here |
| |
| |
| |
|___________________________________________ |
1. A text input field to enter the matrix dimension as an integer;
2. A Submit button to start processing (on the server side);
3. A DIV to show the result matrix.
A user is expected to enter a number in the input field and then click SUBMIT to send the number to the nodeJS server, which generates the matrix based on the input dimension and then displays the result matrix in the browser.
Note: It'd be great if the input (dimension) can be validated with proper error handling.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started