본문 바로가기

Algorithms

freeCodeCamp - 6. Confirm the Ending [Basic Algorithm Scripting]

Confirm the Ending

 

https://www.freecodecamp.org/learn/javascript-algorithms-and-data-structures/basic-algorithm-scripting/confirm-the-ending

 

www.freecodecamp.org

 

function confirmEnding(str, target) {
  if(str.slice(-target.length, str.length) == target) return true 
  return false;
}

confirmEnding("Bastian", "n");