javascript question on my assingment , what would you ever need to do this for?
I have an assignment that requirers the steps below , but I cannot visualize why you would need a webpage form with these things that are required ,
I am very very very new to Javascript !!
thanks so much for any guidence you can give me !!!!!!!!
Create an HTML form.
Create and Initialize three arrays.
Use for-loops to populate those arrays.
Add an element to the end of one array.
Remove an element from the end of another array.
Add a new element to the beginning of one array.
Add at least one additional array method of your choice.
Convert an array to a string.
Use the converted string, assign to a string variable, and use it to populate a form field.
Create different functions to handle the operations of steps 4, 5, 6, and 7. (You can create additional array methods.)
Create four or more buttons on the form with different event handlers to start the above functions upon clicking them.
Create an additional button with an event handler to complete the operation in step 10.
JavaScriptJSONHTMLWeb Development
Last Comment
NAMEWITHELD12
8/22/2022 - Mon
Dave Baldwin
JavaScript handling of form data is a common thing to do. I would say that if you didn't 'interface' with forms, you would have ignored many of the important things that JavaScript is used for. I use JavaScript on virtually every one of the hundreds of form page I have written in the last 8 or 10 years.
NAMEWITHELD12
ASKER
I'm having trouble visualizing how three arrays pre-populated with a for-loop (assuming this really only works with numbers?) would be useful when filling out a form, though....I'm sorry if I seem a little dense on this, but I'm really drawing a blank. I feel like if I had a real world (but easy for a beginner to implement) example of why these steps would need to be done it would make the instructions a little less mystifying....
Moussa Mokhtari
Hi NAMEWITHELD12 it's good thing to question about questions (Why /for what/ how)but some times assignments are just assignments no big goal from it just making you use your brain in non logical way
just work with the flow and answer every question step by step and remember that not every question have have a purpose from it.
Sounds like a convoluted exercise to help you understand how arrays can be used.
What comes to mind is that you can pass data to JavaScript from a server, and that data is often in JSON (JavaScript Object Notation) format. They can contain arrays that you may want to display and in this case let the user edit it via a form.
NAMEWITHELD12
ASKER
No server in this scenario is available, unfortunately. I totally agree, I definitely don't want to psychoanalyze the prof at this point and figure out why these steps are all in one assignment, I think I'd just rage quit the assignment if I did :-) I neglected to mention that at the start of the steps, it tells you the HTML page you build from scratch can be a theme of your own choosing. I, for the life of me, can't think of a theme, so I can't visualize how to implement any of the steps.
i.e. It's an HTML form. A user enters first name, last name, maybe they're filling out a job application or something. The javascript populates three arrays with for-loops that contain, I assume, only random numbers because for-loops can't populate an array with anything else (right?) What would the user use these arrays for? A drop-down list? A.....??