File tree 2 files changed +42
-0
lines changed
2 files changed +42
-0
lines changed Original file line number Diff line number Diff line change
1
+ /* You are given an array:
2
+
3
+ var fruits = ['Apple', 'Banana', 'Orange'];
4
+
5
+ a) Find the index of ‘Banana’ and replace ‘Banana’ with ‘Mango’.
6
+ b) Remove ‘Orange’ and add ‘Watermelon’.
7
+
8
+
9
+
10
+ [View problem source 📤](https://drive.google.com/file/d/1bfxye7A1p-BBJCQCXaiUetl_qyS2Vc1E/view) */
11
+
12
+ var fruits = [ 'Apple' , 'Banana' , 'Orange' ] ;
13
+
14
+
15
+ // Part (a) 1.index of ‘Banana’
16
+ var bananaIndex = fruits . indexOf ( "Banana" ) ;
17
+ console . log ( bananaIndex ) ;
18
+
19
+ // Part (a) 2. replace ‘Banana’ with ‘Mango’.
20
+
21
+ fruits [ 1 ] = 'Mango' ;
22
+ console . log ( fruits ) ;
23
+
24
+ // Part (b) 1. Removing ‘Orange’
25
+
26
+ fruits . pop ( )
27
+ console . log ( fruits ) ;
28
+
29
+ // Part (b) 2. Adding ‘Watermelon’
30
+
31
+ fruits . push ( "Watermelon" ) ;
32
+ console . log ( fruits ) ;
Original file line number Diff line number Diff line change
1
+ You are given an array:
2
+
3
+ var fruits = [ 'Apple', 'Banana', 'Orange'] ;
4
+
5
+ a) Find the index of ‘Banana’ and replace ‘Banana’ with ‘Mango’.
6
+ b) Remove ‘Orange’ and add ‘Watermelon’.
7
+
8
+
9
+
10
+ [ View problem source 📤] ( https://drive.google.com/file/d/1bfxye7A1p-BBJCQCXaiUetl_qyS2Vc1E/view )
You can’t perform that action at this time.
0 commit comments