Skip to content

Commit 4d23144

Browse files
authored
Question No 19 to 21
1 parent 909a49e commit 4d23144

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

README.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -312,3 +312,49 @@ console.log(x)
312312

313313
**[:top: Scroll to Top](#javascript-output-based-interview-questions)**
314314

315+
**19. What will be the output**
316+
```js
317+
console.log('apple'.split(''));
318+
```
319+
<details>
320+
<summary><b>View Answer</b></summary>
321+
<ul>
322+
<li><b>Output</b> : [ 'a', 'p', 'p', 'l', 'e' ]</li>
323+
<li><b>Reason</b> : split method is used to split a string into an array of substrings based on a specified separator </li>
324+
</ul>
325+
</details>
326+
327+
**[:top: Scroll to Top](#javascript-output-based-interview-questions)**
328+
329+
**20. What will be the output**
330+
```js
331+
const arr = [2,3,5,2,8,10,5];
332+
console.log(arr.indexOf(5))
333+
```
334+
<details>
335+
<summary><b>View Answer</b></summary>
336+
<ul>
337+
<li><b>Output</b> : 2</li>
338+
<li><b>Reason</b> : indexOf method returns the index of the first occurrence of the specified element in the array. </li>
339+
</ul>
340+
</details>
341+
342+
**[:top: Scroll to Top](#javascript-output-based-interview-questions)**
343+
344+
**21. What will be the output**
345+
```js
346+
const array = [8, 18, 28, 38];
347+
const result = array.map(element => element + 2)
348+
.filter((element) => element > 25);
349+
console.log(result);
350+
```
351+
<details>
352+
<summary><b>View Answer</b></summary>
353+
<ul>
354+
<li><b>Output</b> : [ 30, 40 ]</li>
355+
<li><b>Reason</b> : The code increments each element in the array by 2 using map and filters out elements greater than 25 using filter,</li>
356+
</ul>
357+
</details>
358+
359+
**[:top: Scroll to Top](#javascript-output-based-interview-questions)**
360+

0 commit comments

Comments
 (0)