I got stuck on a coding challenge that is called All Star Code Challenge #20 on codewars.
I don’t understand something in instructions as below:
Raise an error if input arguments are not of equal length.
Here is the full instruction below:
Create a function called addArrays() that combines two arrays of equal length, summing each element of the first with the corresponding element in the second, returning the "combined" summed array.
Raise an error if input arguments are not of equal length.
Here is my code so far:
function addArrays(array1, array2) {
let newArr = [];
if (array1.length === array2.length) {
for (let i = 0; i < array1.length; i++) {
newArr.push(array1[i] + array2[i]);
}
return newArr;
} else if (array1.length !== array2.length) {
return 'Error';
}
}