Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

Search specific products in the array 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"
]
//Searching laptop product inclues in the array
const searching = "laptop";
const output = [];
for (const product of products) {
    if (product.toLowerCase().indexOf(searching.toLowerCase()) !== -1) {
        output.push(product)
    }
}
console.log(output);
//Output: 
/* [
    'Dell hardcore 129 laptop',
    'yellow laptop with balack camera',
    'Dell 1x59 lenovo commercial yoga Laptop',
    'LG supernove laptop dell',
    'Dell purple color phone with Laptop'
  ] */
Comment

PREVIOUS NEXT
Code Example
Javascript :: how to get data from jsonplaceholder 
Javascript :: Find specific string by using includes in javascript 
Javascript :: javascript unique id generator 
Javascript :: js comment out 
Javascript :: invite tracker node.js v13 
Javascript :: jq query online tutorial 
Javascript :: convert string to charcode js 
Javascript :: nodejs RPL 
Javascript :: tictactoe - javascript 
Javascript :: nestjs pg heroku 
Javascript :: runecape 
Javascript :: javascript auto detect if select input changed 
Javascript :: rename data table button 
Javascript :: waitfordisplayed 
Javascript :: save canvas from console 
Javascript :: Get javascript object from array by filter 
Javascript :: template.json input parameters 
Javascript :: reactjs ES6 class event listeners in jsx 
Javascript :: fetch hook 
Javascript :: JS call url many times 
Javascript :: <Link> react import 
Javascript :: implict type coercion in js 
Javascript :: jquery ui music player 
Javascript :: js decrypt online 
Javascript :: how to load image in hbs document 
Javascript :: how to get the folder of the extension 
Javascript :: Starting the project 
Javascript :: reverse not working react 
Javascript :: jsondb 
Javascript :: show route between markers google maps javascript 
ADD CONTENT
Topic
Content
Source link
Name
7+8 =