Tell us what’s happening:
Got it to pass all but one. It returns true because the n in “specification” and the n in “frozen” both end in n, so it goes to true. I’m not sure what to do next to verify that.
Your code so far
function confirmEnding(string,stringCheck){
//gives the index number of last index of stringCheck within string
const stringLastOccurenceStartsWith = string.lastIndexOf(stringCheck)
//using these to do the checks
//gives the first letter of the first occurrence of stringCheck
const lastStartsWith = string[stringLastOccurenceStartsWith]
console.log("Last Occurence of stringCheck in String: " + lastStartsWith)
//gives the first letter in stringCheck
const stringCheckStartsWith = stringCheck[0]
console.log("First letter in stringCheck: " + stringCheckStartsWith)
//give the last letter in the string
const stringEndsWith = string.slice(string.length-1)
console.log("Last Letter in String(should): " +stringEndsWith)
//gives the last letter in stringCheck
const stringCheckEndsWith = stringCheck.slice(stringCheck.length-1)
console.log("Last letter in stringCheck: " + stringCheckEndsWith)
//maybe need to checking half the word
if(lastStartsWith === stringCheckStartsWith && stringEndsWith === stringCheckEndsWith){
console.log("true")
return true;
}else {
console.log("false")
return false
}
}
confirmEnding("Connor", "n")
confirmEnding("Walking on water and developing software from a specification are easy if both are frozen", "specification")
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/143.0.0.0 Safari/537.36
Challenge Information:
Build a Confirm the Ending Tool - Build a Confirm the Ending Tool