--- id: acda2fb1324d9b0fa741e6b5 title: Confirma el final challengeType: 5 forumTopicId: 16006 dashedName: confirm-the-ending --- # --description-- Evalúa si una cadena (primer argumento, `str`) termina con la cadena de destino dada (segundo argumento, `target`). Este desafío *puede* resolverse con el método `.endsWith()`, que fue introducido en ES2015. Pero para el propósito de este desafío, nos gustaría que usaras uno de los métodos de subcadena de JavaScript en su lugar. # --hints-- `confirmEnding("Bastian", "n")` debe devolver `true`. ```js assert(confirmEnding('Bastian', 'n') === true); ``` `confirmEnding("Congratulation", "on")` debe devolver `true`. ```js assert(confirmEnding('Congratulation', 'on') === true); ``` `confirmEnding("Connor", "n")` debe devolver `false`. ```js assert(confirmEnding('Connor', 'n') === false); ``` `confirmEnding("Walking on water and developing software from a specification are easy if both are frozen", "specification")` debe devolver `false`. ```js assert( confirmEnding( 'Walking on water and developing software from a specification are easy if both are frozen', 'specification' ) === false ); ``` `confirmEnding("He has to give me a new name", "name")` debe devolver `true`. ```js assert(confirmEnding('He has to give me a new name', 'name') === true); ``` `confirmEnding("Open sesame", "same")` debe devolver `true`. ```js assert(confirmEnding('Open sesame', 'same') === true); ``` `confirmEnding("Open sesame", "sage")` debe devolver `false`. ```js assert(confirmEnding('Open sesame', 'sage') === false); ``` `confirmEnding("Open sesame", "game")` debe devolver `false`. ```js assert(confirmEnding('Open sesame', 'game') === false); ``` `confirmEnding("If you want to save our world, you must hurry. We dont know how much longer we can withstand the nothing", "mountain")` debe devolver `false`. ```js assert( confirmEnding( 'If you want to save our world, you must hurry. We dont know how much longer we can withstand the nothing', 'mountain' ) === false ); ``` `confirmEnding("Abstraction", "action")` debe devolver `true`. ```js assert(confirmEnding('Abstraction', 'action') === true); ``` Tu código no debe usar el método incorporado `.endsWith()` para resolver el desafío. ```js assert(!/\.endsWith\(.*?\)\s*?;?/.test(code) && !/\['endsWith'\]/.test(code)); ``` # --seed-- ## --seed-contents-- ```js function confirmEnding(str, target) { return str; } confirmEnding("Bastian", "n"); ``` # --solutions-- ```js function confirmEnding(str, target) { return str.substring(str.length - target.length) === target; } confirmEnding("Bastian", "n"); ```