I have a search field which filters through an array when I’m typing. So far it works ok, but I cannot search within the “courses” array! How can I achieve this? The complete array looks like this: Here is my JS code so far, where I can search through all fields, except the “courses”-array: Can someone help me out? Answer
Tag: filter
Combine javascript functions to work together
I am building a search form that filters the results based on the a text input as well as select options from four separate drop-downs (category, sub-category, location, etc). The following two functions work well, but I just realized that if I type a search term in the input, make my drop-down selections and then go back and type a
JS Array.prototype.filter with Array extending class constructor call
I have a Array extending class A which I want to filter. It seems like the constructor gets called another time with just 0 as parameter. Why is that? Here is an example showing the problem: Which logs: Where is the 0 comming from? Answer Array.prototype.filter is returning a new (array) value. That value needs to be of the same
filtering array in range of array time and time now javascript
i get some trouble when i try to filtering time now in array time, i have code like this ; the problem is output not same with my expectation. i want : if timeNow is 08, timeShift output(selected) is 08, if timeNow is 07, timeShift output(selected) is 06, if timeNow is 09, timeShift output(selected) is 08, if timeNow is 23,
JavaScript: Looping through an array of objects and filtering specific properties/attributes
I’m trying to loop through an array and return just the addresses and the number of packages and then having the total number of packages in the array added up. Problem is, when I write this all in codepen.io, it tells me that each name attribute is having an unexpected identifier error. I know I’ll have to work on the
HTML datalist keeps crashing when dynamically loaded with Vue
I’m using Vue.js to load an HTML datalist. Whenever I type in my input box that is connected to my datalist, my page freezes (using Chrome). I’m using jQuery to make an AJAX call to initially get all of my users when the page loads, then using the JavaScript filter function to make a new array that has indexOf whatever
vue v-for with filter gives error
I’m trying to use a local filter with v-for but I’m getting an error Property or method “filterByTitle” is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property. Code below Answer Filters are limited in Vue 2 primarily to formatting
Filter object properties by key in ES6
Let’s say I have an object: I want to create another object by filtering the object above so I have something like. I am looking for a clean way to accomplish this using Es6, so spread operators are available to me. Answer If you have a list of allowed values, you can easily retain them in an object using: This
Return index value from filter method javascript
I have an array of objects in my angular controller. I want to return the value of the index of the field within the array which has a matching ID to my parameter. There will only be one object in the array with a matching fieldId.. Answer You can’t return index from filter method. The filter() method creates a new