[javascript] FE Dev screening
Viewer
*** This page was generated with the meta tag "noindex, nofollow". This happened because you selected this option before saving or the system detected it as spam. This means that this page will never get into the search engines and the search bot will not crawl it. There is nothing to worry about, you can still share it with anyone.
- const applyFilter = (_data, filters) => {
- const filteredData = _data.filter(item => {
- let dataPaired = []
- filters.forEach(filter => {
- if (filter.type === 'search') {
- const searchColumn = filter.searchColumn.split(',')
- dataPaired = [...dataPaired, searchColumn.some(key => {
- const searchTerm = filter.value.trim().toLowerCase()
- const columnData = item[key]
- if (Array.isArray(columnData)) {
- // If the column data is an array, we need to check if any of the items in the array contains the search term
- } else {
- return String(columnData).toLowerCase().includes(searchTerm)
- }
- })]
- }
- })
- return !dataPaired.includes(false)
- })
- setData(filteredData)
- }
Editor
You can edit this paste and save as new:
File Description
- FE Dev screening
- Paste Code
- 23 Mar-2023
- 952 Bytes
You can Share it:
Latest Code Pastes