You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
**Question 8:** Create a JavaScript **Function** to find the area of a triangle where lengths of the three of its sides are 5, 6, 7
168
+
169
+
```js
170
+
input :area_of_triangle(5,6,7)
171
+
output :14.69
172
+
```
173
+
**Question 9:** Create a JavaScript **Function** to capitalize the first letter of each word of a given string.
174
+
```js
175
+
176
+
input :capitalize("we are the champions")
177
+
output :"We Are The Champions"
178
+
179
+
180
+
```
181
+
167
182
## Chapter 4 (Objects)
168
183
169
184
### Assignments
@@ -238,6 +253,14 @@ for(let elem in arr){
238
253
}
239
254
```
240
255
256
+
**Question 9:** You have to create a **Shopping_Cart** array with following features :
257
+
258
+
-**addItem(itemName)** : this function should add string itemName to cart
259
+
260
+
-**removeItem(itemName)**: this function should remove any item which matches itemName. _Hint : search for index of itemName and then remove it_
261
+
262
+
-**cartSize()** : returns size of cart in terms of number of cart Items.
263
+
241
264
242
265
## Chapter 5 (DOM)
243
266
@@ -387,11 +410,70 @@ let arr = [1,2,3,4];
387
410
let result =arr.splice(1,2).pop();
388
411
console.log(result);
389
412
```
390
-
**Question 13:** You have given an array of numbers **nums**. You have to check if all elements of the **array > 15** using **built-in** array method.
413
+
**Question 13:** You have `given an array of numbers **nums**. You have to check if all elements of the **array > 15** using **built-in** array method.
391
414
```js
392
415
let nums = [16,17,18,28,22];
393
416
```
394
417
418
+
### More Practice Questions (Arrays)
419
+
420
+
**Question 1:** Guess the **Output** And explain Why?
421
+
422
+
```js
423
+
let strArray = [1,2,3,4,5];
424
+
let result =strArray.reverse();
425
+
console.log(result == strArray);
426
+
```
427
+
**Question 2:** You have **given** two **arrays** below as an example. Your task is to **combine** them into one By using array method
428
+
```js
429
+
input
430
+
let arr1 = [1,2,3,4,5];
431
+
let arr2 = [6,7,8,9,10];
432
+
ouput
433
+
[6,7,8,9,10,1,2,3,4,5]
434
+
```
435
+
**Question 3:** You have given an array of **letters** below. Convert that array into string of letters **Without Space**
436
+
437
+
```js
438
+
input
439
+
let arr = ['a','b','h','i','s','h','e','k'];
440
+
output
441
+
'abhishek'
442
+
```
443
+
444
+
**Question 4:** Guess the **Output** and explain why?
445
+
```js
446
+
let arr = [11,62,1,27,8,5];
447
+
let sorted =arr.sort();
448
+
console.log(sorted)
449
+
```
450
+
451
+
**Question 5:** Create a function 'calcAverageHumanAge', which accepts an arrays of dog's ages ('ages'), and does the following thing in order:
452
+
1. Calculate the dog age in human years using the following formula: if the dog is <= 2 years old, humanAge = 2 * dogAge. If the dog is > 2 years old, humanAge = 16 + dogAge
453
+
```js
454
+
Test data
455
+
456
+
let arr = [12,2,5,12,8,13,9];
457
+
```
458
+
459
+
**Question 6:** Guess the **Output** and Explain Why?
460
+
461
+
```js
462
+
let arr = [1,2,3,4,5,6,7,8]
463
+
let elem =arr.at(-1);
464
+
console.log(elem);
465
+
```
466
+
467
+
**Question 7:** Guess the **Output** and Explain why?
468
+
```js
469
+
let arr = [1,2,3,4,5,6,7,8]
470
+
let result =arr.slice(2,5).splice(0,2,21).pop();
471
+
console.log(result,arr)
472
+
```
473
+
474
+
475
+
476
+
395
477
## Chapter 8 (Date and Time)
396
478
397
479
### Assignments
@@ -648,6 +730,81 @@ for(let key of nums) {
648
730
}
649
731
```
650
732
733
+
### More Practice Questions
734
+
735
+
**Question 1:** Guess the **Output** and Explain Why?
736
+
```js
737
+
let arr = [1,2,3,4,5];
738
+
let arr1 = [...arr];
739
+
arr1[2] = 10;
740
+
console.log(arr,arr1)
741
+
```
742
+
**Question 2:** You have given a list of variable names written in underscore. You have to write a program to convert them into camel casing format
743
+
744
+
```js
745
+
List of variable names
746
+
747
+
Input
748
+
user_name
749
+
last_name
750
+
date_of_birth
751
+
user_password
752
+
753
+
Output
754
+
userName
755
+
lastName
756
+
dateOfBirth
757
+
userPassword
758
+
```
759
+
**Question 3:** Guess the **Output** and Explain why?
0 commit comments