Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

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

PREVIOUS NEXT
Code Example
Javascript :: SharePoint Rest Api in Batch using PnP JS 
Javascript :: tour-app-api 
Javascript :: javascript id generator 
Javascript :: facade js 
Javascript :: regex expression for password uppercase lowercase specil character , number in js 
Javascript :: js what does the vertical line symbol do 
Javascript :: char code to string javascript 
Javascript :: nodejs process object 
Javascript :: focus on child components on single page applications - 1 
Javascript :: jquery excel export 
Javascript :: how to access res.locals in express 
Javascript :: assignment of struct in solidity 
Javascript :: requiere and get a property simplified with Node 
Javascript :: variable local and global 
Javascript :: PASSWORD REDIRECT 
Javascript :: how to cookie set in node js 
Javascript :: create immutable array in javascript 
Javascript :: react controllers 
Javascript :: using fetch hook 
Javascript :: JavaScript call url many times 
Javascript :: "["value"]" to array js 
Javascript :: Filters in Algolia search 
Javascript :: loop with multiple conditions js codesmith 
Javascript :: error 28 mongodb 
Javascript :: Function for masking the character 
Javascript :: utterances reactjs 
Javascript :: custom validator Whitelisting 
Javascript :: how to identify the li anchor tag text is empty in javascript 
Javascript :: observables loop in template angular 8 
Javascript :: Enable Cookies and JavaScript in Internet Explorer 9.0 
ADD CONTENT
Topic
Content
Source link
Name
5+9 =