Blockquote
Step 7 Passed (Number Sorter)
You need to get the values from yourselect
elements. These values will currently be strings and you will convert them into numbers.
Use themap
function to iterate over the array. Pass a callback function tomap
that takes adropdown
parameter and returnsdropdown.value
.
I passed this step but having trouble understanding this:
const sortInputArray = (event) => {
event.preventDefault();
const inputValues = [...document.getElementsByClassName("values-dropdown")].map((something) => (something.value));
console.log(inputValues);
The console shows: [ ‘8’, ‘2’, ‘4’, ‘1’, ‘3’ ]
const inputValues = [...document.getElementsByClassName("values-dropdown")];
console.log(inputValues)
Provides all possible select values as objects within an array which makes sense.
The part that I am not getting is why does mapping a previously undefined callback function automatically determine what information is in the select boxes without explicity linking the select box .value individually? Sorry for poorly articulating this, thanks in advance.