I’ve looked at the answers and see that there are easier ways to complete this challenge but i was wondering if anyone could see what was going wrong with my code? It matches for one word inputs but not for multiple inputs.
function confirmEnding(str, target) {
let word = ""
for (let i = 0; i < target.length; i++) {
if (target[i] == str[str.length-i-1]) {
word += target[i];
}
}
if (word == target) {
return true;
} else {
return false;
}
}
confirmEnding("Congratulation", "on");
took a while but i figured it out now i have a headache. its still hard for me to remember all the commands to make things easier
function confirmEnding(str, target) {
let word = ""
for (let i = 0; i < target.length; i++) {
let x = ((target.length) - i)
console.log([x])
console.log(str[str.length-x])
if (target[i] == str[str.length-x]) {
word += target[i];
}
}
if (word == target) {
return true;
} else {
return false;
}
}
confirmEnding("Congratulation", "on");