const data = [
{
id: "1",
name: "Apple iPhone 5c",
memory: "16GB, 32GB and RAM 1 GB"
},
{
id: "2",
name: "Apple iPhone 6",
memory: "16GB, 32GB and RAM 1 GB"
},
{
id: "3",
name: "Lenovo A6000",
memory: "16GB, 32GB and RAM 1 GB"
}
]
le
[
{
id: "3",
name: "Lenovo A6000",
memory: "16GB, 32GB and RAM 1 GB"
}
]
const lowered = str.toLowerCase();
const filtered = [];
for (const n of data) {
if (!n.name.toLowerCase().indexOf(lowered)) {
filtered.push(n);
}
}
const filtered = data.filter(function(n) {
return n.name.toLowerCase().startsWith(this);
}, str.toLowerCase());
const filtered = (function get(reg, i, n = data[i]) {
return n
? [].concat(reg.test(n.name) ? n : [], get(reg, -~i))
: [];
})(RegExp(`^${str}`, 'i'), 0);
mySearch(arr,search)