Skip to content

Commit fad12e4

Browse files
problem 7 solved
1 parent 5425e72 commit fad12e4

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

problem7/proble7.js

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
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);

problem7/problem.md

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
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)

0 commit comments

Comments
 (0)