Im stuck on this error message, would anyone be able to help me with this please.
The challenge: Complete the solution so that it returns true if the first argument(string) passed in ends with the 2nd argument (also a string).
My code:
function solution(str, ending){
var arrayStr = str.split('').reverse();
var arrayEnding = ending.split('').reverse();
if (arrayStr.length !== arrayEnding.length) {
var n = arrayEnding.length;
var arrayStr1 = arrayStr.slice(0, n);
};
for (i = 0; i < arrayEnding.length; i++) {
for (j = 0; j < arrayStr1.length; j++) {
if (arrayEnding[i] == arrayStr1[j]) {
i++;
j++;
} else if (arrayEnding[i] !== arrayStr1[j]) {
return false;
};
} return true;
};
};