Answers for "Search products by includes in javascript"

0

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'
// ]
Posted by: Guest on December-25-2021

Code answers related to "Search products by includes in javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language