Horje
Search specific products in the array in javascript Code Example
Search specific products in the array in javascript
const products = [
    "Dell hardcore 129 laptop",
    "iphone 1Tb camera flashlight phone",
    "yellow laptop with balack camera",
    "Dell 1x59 lenovo commercial yoga Laptop",
    "LG supernove laptop dell",
    "HTC low price phone",
    "Dell purple color phone with Laptop"
]
//Searching laptop product inclues in the array
const searching = "laptop";
const output = [];
for (const product of products) {
    if (product.toLowerCase().indexOf(searching.toLowerCase()) !== -1) {
        output.push(product)
    }
}
console.log(output);
//Output: 
/* [
    'Dell hardcore 129 laptop',
    'yellow laptop with balack camera',
    'Dell 1x59 lenovo commercial yoga Laptop',
    'LG supernove laptop dell',
    'Dell purple color phone with Laptop'
  ] */




Javascript

Related
semantic UI react focus on input Code Example semantic UI react focus on input Code Example
copy link url javascript Code Example copy link url javascript Code Example
date and month are swapping in angular Code Example date and month are swapping in angular Code Example
get the first value when mapping through the array Code Example get the first value when mapping through the array Code Example
how to add two var in javascript Code Example how to add two var in javascript Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
6