Replacing last element of an Array
Replace the last element of the given array with the given second parameter. Return an updated array.
Sample Code:
function replaceEle(arr,inp) {
// Enter your logic here...
}
Examples:
Input: [1,2,3],[3.1]
Output: [1,2,[3.1]]
Explanation: The last element 3 has been replaced by [3.1].
Input: ['c','o','d','?'],'e'
Output: ['c','o','d','e']
Explanation: The last element '?' has been replaced by 'e'.