Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

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'
// ]
Comment

PREVIOUS NEXT
Code Example
Javascript :: Dynamically Generated Table 
Javascript :: signed url to get file from s3 bucket 
Javascript :: javascript uuid generator 
Javascript :: tabindex 
Javascript :: Fabricjs configurations 
Javascript :: Temporarily Edit Text on Any Website 
Javascript :: common library for .net and node js for encryption 
Javascript :: node.js core modules 
Javascript :: focus on child components on single page applications - 2 
Javascript :: Replacing Specific word from url, replacing url 
Javascript :: Setting, getting, and removing data attributes vanilla javascript 
Javascript :: how to return a value to the parent function from ajax javascript 
Javascript :: karma get attribute 
Javascript :: javascript centuries 
Javascript :: how to input struct into parameter in remix 
Javascript :: js invert array 
Javascript :: sw.js 
Javascript :: functional-javascript-workshop solutions 
Javascript :: reload stylesheet with out refresh page 
Javascript :: javascript variable without value 
Javascript :: javascript stopped working 
Javascript :: gitignore jsconfig 
Javascript :: how to create an object that stores personal data in javascript 
Javascript :: get index from for in loop javascript 
Javascript :: js dom after selectors 
Javascript :: javascript intersection recursion 
Javascript :: on change jquery kendo switch 
Javascript :: material ui refresh icon 
Javascript :: react weather app 
Javascript :: highlight row javascript 
ADD CONTENT
Topic
Content
Source link
Name
3+9 =