I need help finding out exactly how I should use the filter.
The following works fine:
let nums = [10, 12, 15, 20] nums.filter(num => num > 14)
result = [15, 20]
If I understand this correctly, I pass a function with the argument num as an argument.
Now here where everything gets confusing (Keep in mind that I'm not an advanced js programmer)
I have an array of html elements
let fields = document.getElementsByClassName("f-field")
Each element of the returned array contains a bunch of other html elements, it looks something like this.
<div class="f-field"> <textarea id="9008" name="Logo"></textarea> </div>
Internal HTML can be textareas, selects, input, whatever ...
I tried this and he says
"fields.filter is not a function"
fields.filter(field => field.getElementsByName("Logo"))
I assume the filter does not work for an array of html elements. Or am I doing it wrong?
Thanks in advance, I'm trying to understand javascript
source share