Answers for "Write a JS function that takes 2 arguments: a sentence (string) and a word (substring). The function tells whether the sentence ends with the given substring. If yes, the function returns true and if not, the function returns false."

0

how to compare a string with its ending in javascript

function solution(str, ending){
  return str.indexOf(ending, str.length - ending.length) !== -1;
}
Posted by: Guest on March-23-2020

Code answers related to "Write a JS function that takes 2 arguments: a sentence (string) and a word (substring). The function tells whether the sentence ends with the given substring. If yes, the function returns true and if not, the function returns false."

Code answers related to "Javascript"

Browse Popular Code Answers by Language