Hello! I have two different answers for this challenge, one results in ‘[ 5, 27, 39, 1001 ]’, the other in ‘5, 27, 39, 1001’. I can’t figure out how to remove the apostrophe while keeping the brackets. Here are my two separate pieces of code:
This is the one with ‘[]’:
function largestOfFour(arr) {
arr.forEach(function(arr1) {
return arr1.sort(function(a, b) {
return b - a;
});
});
arr.forEach(function(arr1) {
return arr1.splice(1);
});
var result = arr.join();
return '[' + result + ']';
}
largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
This is the one with ‘’:
function largestOfFour(arr) {
arr.forEach(function(arr1) {
return arr1.sort(function(a, b) {
return b - a;
});
});
arr.forEach(function(arr1) {
return arr1.splice(1);
});
return arr.join(" ");
}
largestOfFour([[4, 5, 1, 3], [13, 27, 18, 26], [32, 35, 37, 39], [1000, 1001, 857, 1]]);
Thank you for your help! -Marie