A challenge I am facing involves an array with multiple elements. My goal is to remove the last two digits from any element in the array that consists of 3 or 4 digits, while leaving elements with 1 or 2 digits unchanged.
var test =[ 2, 45,567, 3, 6754];
The desired output is :
[ 2, 45, 5, 3, 67];
I attempted a solution using:
test.forEach(function(element, index) { test[index] = element.slice(1, -2); });
However, this approach resulted in blanking out single-digit elements.