File tree 1 file changed +7
-24
lines changed 1 file changed +7
-24
lines changed Original file line number Diff line number Diff line change 1
- // String includes() - checks if a string contains another string.
1
+ // Array includes() - checks if a string contains another string.
2
+ // Array includes - checks if the item is an array
2
3
3
- console . log ( "=== Case Sensitive ===" ) ;
4
- const product = {
5
- title : "Leather Chair" ,
6
- } ;
7
- console . log ( product . title . includes ( "le" ) ) ;
4
+ const groceries = [ "milk" , "apple" , "banana" , "carrot" ] ;
8
5
9
- console . log ( "=== 2nd Argument ===" ) ;
10
- const firstName = "peter" ;
11
- const result = firstName . includes ( "pe" , 0 ) ;
12
- console . log ( result ) ;
6
+ let item = "lemon" ;
7
+ item = "milk" ;
13
8
14
- /* Products */
15
- const products = [
16
- { title : "Modern Poster" } ,
17
- { title : "Bar Stool" } ,
18
- { title : "Armchair" } ,
19
- { title : "Leather Chair" } ,
20
- ] ;
21
-
22
- const searchTitle = "a" ;
23
-
24
- const filteredProducts = products . filter ( ( item ) =>
25
- item . title . toLowerCase ( ) . includes ( searchTitle )
26
- ) ;
27
- console . log ( filteredProducts ) ;
9
+ const isItemIncluded = groceries . includes ( item , 1 ) ;
10
+ console . log ( isItemIncluded ) ;
You can’t perform that action at this time.
0 commit comments