Horje
Search products by includes in javascript Code Example
Search products by includes 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"
]

//Method Two
const searching = "phone";
const output = [];
for (const product of products) {
    if (product.toLowerCase().includes(searching.toLowerCase())) {
        output.push(product)
    }
}
console.log(output);
//Output:
// [
//     'iphone 1Tb camera flashlight phone',
//     'HTC low price phone',
//     'Dell purple color phone with Laptop'
// ]




Javascript

Related
30 mins 24 hours jquery loop Code Example 30 mins 24 hours jquery loop Code Example
how to check for special characters on a phone number with js Code Example how to check for special characters on a phone number with js Code Example
cookie-parser in node js Code Example cookie-parser in node js Code Example
jquery.MultiFile Code Example jquery.MultiFile Code Example
myModal Code Example myModal Code Example

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