Sorry for this basic question... I am relatively new to JS.
I have two arrays and want to select values from one based on the values of the other.
For example, if I have
var student = [10, 11, 21, 30, 31, 14];
var class = [1, 1, 2, 3, 3, 1];
How would I proceed (ideally with filter and/or map) to get the list of student numbers in class = 1, for example.
I know how I would do it with a for-loop and push() function, but I think there should be a more elegant/concise way to perform that task in a single line command with map, filter or other functions.
Thanks in advance for any help.
forloop sounds pretty elegant to me tbh.class = 1? perhaps demonstrate what you have tried with the for-loop andpushapproach?