Tell us what’s happening: How can i group the letters in the second parameter without caring for the order they are in ? My code is half complete. Ik there are other ways to do this challenge but is it possible to use regex ? help is appretiated
Your code so far
function mutation(arr) {
let one = arr[0];
let two= arr[1];
let testRegex = new RegExp((two), "ig");
let result = testRegex.test(one);
return result
}
mutation(["hello", "hey"]);
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36.
I’d say doing it with regex isn’t impossible, but absolutely unsuited for this particular challenge. Currently, you check if the characters in two can be found in onein that order.
Example: mutation(["hello","hell"]) would correctly return true with your approach. mutation(["hello","lleh"]) would (incorrectly) return false.
You’d have to check individual characters, so it would make more sense to split('') both strings and then use array methods like includes() or indexOf() to compare the letters.