Question
Consider the following code: Â Â let data = [1,
2, 3]; Â Â function modifyArray(arr) { Â Â Â Â arr.push(4); Â Â Â Â arr = [5, 6]; // Reassigns local 'arr' Â Â Â Â return arr; Â Â } Â Â let result = modifyArray(data); Â Â console.log(data); Â Â console.log(result); Â Â What will be the output?Solution
1. data is [1, 2, 3].   2. modifyArray(data) is called. arr inside the function initially refers to the same array as data.   3. arr.push(4) modifies the original array that data also points to. So, data is now [1, 2, 3, 4].   4. arr = [5, 6] reassigns the local variable arr to a new array [5, 6]. This does not affect the data variable in the global scope.   5. The function returns the new array [5, 6], which is assigned to result.   Therefore, data is [1, 2, 3, 4] and result is [5, 6].
The simple interest earned on ₹3,000 at a rate of 8% per annum for 4 years is ₹x. If ₹2,520 is the simple interest earned on ₹5,000 at a rate of...
A sum of Rs. 30,000 is invested in SIP 'C' which offers 12% p.a. simple interest for 3 years. The interest received from SIP 'C' is invested in SIP 'D' ...
Akshay invested Rs. 2240 in two schemes P and Q in the respective ratio of 9:7. Scheme P and Q are offering simple interest at the rate of 10% per annum...
A man invested a certain amount of sum at 12.5% per annum simple interest and earned an interest of Rs. 2700 after 3 years. If the same amount is...
A person invested Rs. 75,000 at an annual compound interest rate of 12%, compounded annually for 12 months. How much more profit would he have earned if...
A sum is lent on compound interest for 2 years at 13% p.a. If the compound interest on the sum is Rs.3045.9, find the sum.
- A man took a loan at a rate of 18% per annum simple interest. After 42 months, he paid Rs. 9,240 to clear his dues. Find the initial loan amount.
'R' took a loan of Rs. 40,000 from a bank with a compound interest rate of 15% per annum and then invested the same amount at a s...
Amit invested Rs. 8,500 for 5 years in a scheme offering simple interest at 10% per annum. He distributed the total amount received by him from the sche...
- A businessman took a loan at 25% p.a. simple interest. After 40 months, he repaid Rs. 12,500 to clear the loan. Find the principal amount borrowed.