3.7 KiB
3.7 KiB
id, title, localeTitle, isRequired, challengeType
id | title | localeTitle | isRequired | challengeType |
---|---|---|---|---|
af2170cad53daa0770fabdea | Mutations | Mutaciones | true | 5 |
Description
["hello", "Hello"]
, debería devolver verdadero porque todas las letras en la segunda cadena están presentes en el primer caso, ignorando el caso.
Los argumentos ["hello", "hey"]
deben devolver falso porque la cadena "hola" no contiene una "y".
Por último, ["Alien", "line"]
, debe devolver verdadero porque todas las letras en "line" están presentes en "Alien".
Recuerda usar Read-Search-Ask si te atascas. Escribe tu propio código.
Instructions
Tests
tests:
- text: ' <code>mutation(["hello", "hey"])</code> debe devolver falso.'
testString: 'assert(mutation(["hello", "hey"]) === false, "<code>mutation(["hello", "hey"])</code> should return false.");'
- text: ' <code>mutation(["hello", "Hello"])</code> debe devolver verdadero.'
testString: 'assert(mutation(["hello", "Hello"]) === true, "<code>mutation(["hello", "Hello"])</code> should return true.");'
- text: ' <code>mutation(["zyxwvutsrqponmlkjihgfedcba", "qrstu"])</code> debe devolver verdadero.'
testString: 'assert(mutation(["zyxwvutsrqponmlkjihgfedcba", "qrstu"]) === true, "<code>mutation(["zyxwvutsrqponmlkjihgfedcba", "qrstu"])</code> should return true.");'
- text: 'la <code>mutation(["Mary", "Army"])</code> debería devolver la verdad.'
testString: 'assert(mutation(["Mary", "Army"]) === true, "<code>mutation(["Mary", "Army"])</code> should return true.");'
- text: 'la <code>mutation(["Mary", "Aarmy"])</code> debe devolver la verdad.'
testString: 'assert(mutation(["Mary", "Aarmy"]) === true, "<code>mutation(["Mary", "Aarmy"])</code> should return true.");'
- text: ' <code>mutation(["Alien", "line"])</code> debe devolver true.'
testString: 'assert(mutation(["Alien", "line"]) === true, "<code>mutation(["Alien", "line"])</code> should return true.");'
- text: ' <code>mutation(["floor", "for"])</code> debe devolver verdadero.'
testString: 'assert(mutation(["floor", "for"]) === true, "<code>mutation(["floor", "for"])</code> should return true.");'
- text: ' <code>mutation(["hello", "neo"])</code> debe devolver falso.'
testString: 'assert(mutation(["hello", "neo"]) === false, "<code>mutation(["hello", "neo"])</code> should return false.");'
- text: ' <code>mutation(["voodoo", "no"])</code> debe devolver falso.'
testString: 'assert(mutation(["voodoo", "no"]) === false, "<code>mutation(["voodoo", "no"])</code> should return false.");'
Challenge Seed
function mutation(arr) {
return arr;
}
mutation(["hello", "hey"]);
Solution
function mutation(arr) {
let hash = Object.create(null);
arr[0].toLowerCase().split('').forEach(c => hash[c] = true);
return !arr[1].toLowerCase().split('').filter(c => !hash[c]).length;
}
mutation(["hello", "hey"]);