4.5 KiB
4.5 KiB
id | title | isRequired | challengeType | videoUrl | localeTitle |
---|---|---|---|---|---|
acda2fb1324d9b0fa741e6b5 | Confirm the Ending | true | 5 | Confirmar el final |
Description
str
) termina con la cadena de destino dada (segundo argumento, target
). Este desafío se puede resolver con el método .endsWith()
, que se introdujo en ES2015. Pero para el propósito de este desafío, nos gustaría que utilices uno de los métodos de subcadena de JavaScript. Recuerda usar Read-Search-Ask si te atascas. Escribe tu propio código. Instructions
Tests
tests:
- text: '<code>confirmEnding("Bastian", "n")</code> debe devolver verdadero.'
testString: 'assert(confirmEnding("Bastian", "n") === true, "<code>confirmEnding("Bastian", "n")</code> should return true.");'
- text: '<code>confirmEnding("Congratulation", "on")</code> debe devolver verdadero.'
testString: 'assert(confirmEnding("Congratulation", "on") === true, "<code>confirmEnding("Congratulation", "on")</code> should return true.");'
- text: '<code>confirmEnding("Connor", "n")</code> debe devolver falso.'
testString: 'assert(confirmEnding("Connor", "n") === false, "<code>confirmEnding("Connor", "n")</code> should return false.");'
- text: '<code>confirmEnding("Walking on water and developing software from a specification are easy if both are frozen", "specification")</code> debe devolver falso.'
testString: 'assert(confirmEnding("Walking on water and developing software from a specification are easy if both are frozen", "specification") === false, "<code>confirmEnding("Walking on water and developing software from a specification are easy if both are frozen", "specification")</code> should return false.");'
- text: '<code>confirmEnding("He has to give me a new name", "name")</code> debe devolver verdadero.'
testString: 'assert(confirmEnding("He has to give me a new name", "name") === true, "<code>confirmEnding("He has to give me a new name", "name")</code> should return true.");'
- text: '<code>confirmEnding("Open sesame", "same")</code> debe devolver true.'
testString: 'assert(confirmEnding("Open sesame", "same") === true, "<code>confirmEnding("Open sesame", "same")</code> should return true.");'
- text: '<code>confirmEnding("Open sesame", "pen")</code> debe devolver falso.'
testString: 'assert(confirmEnding("Open sesame", "pen") === false, "<code>confirmEnding("Open sesame", "pen")</code> should return false.");'
- text: '<code>confirmEnding("Open sesame", "game")</code> debe devolver falso.'
testString: 'assert(confirmEnding("Open sesame", "game") === false, "<code>confirmEnding("Open sesame", "game")</code> should return false.");'
- text: '<code>confirmEnding("If you want to save our world, you must hurry. We dont know how much longer we can withstand the nothing", "mountain")</code> debería devolver el valor falso.'
testString: '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, "<code>confirmEnding("If you want to save our world, you must hurry. We dont know how much longer we can withstand the nothing", "mountain")</code> should return false.");'
- text: '<code>confirmEnding("Abstraction", "action")</code> debe devolver verdadero.'
testString: 'assert(confirmEnding("Abstraction", "action") === true, "<code>confirmEnding("Abstraction", "action")</code> should return true.");'
- text: No use el método <code>.endsWith()</code> para resolver el desafío.
testString: 'assert(!(/\.endsWith\(.*?\)\s*?;?/.test(code)) && !(/\["endsWith"\]/.test(code)), "Do not use the built-in method <code>.endsWith()</code> to solve the challenge.");'
Challenge Seed
function confirmEnding(str, target) {
// "Never give up and good luck will find you."
// -- Falcor
return str;
}
confirmEnding("Bastian", "n");
Solution
// solution required