Horje
Search products by startsWith in javascript Code Example
Search products by startsWith 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"
]
//Search start with 
const searching = "Dell";
const output = [];
for (const product of products) {
    if (product.toLowerCase().startsWith(searching.toLowerCase())) {
        output.push(product)
    }
}
console.log(output);
//Output:
// [
//     'Dell hardcore 129 laptop',
//     'Dell 1x59 lenovo commercial yoga Laptop',
//     'Dell purple color phone with Laptop'
// ]




Javascript

Related
sort callback function Code Example sort callback function Code Example
nodejs  css cotent tipe Code Example nodejs css cotent tipe Code Example
add onmouseover event in javascript Code Example add onmouseover event in javascript Code Example
online code converter javascript to typescript Code Example online code converter javascript to typescript Code Example
immediate promise resolve Code Example immediate promise resolve Code Example

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