I am trying to understand what to do next. I can do a inner loop to check if the words are equal but before that do I need to sort out letters in words
Your code so far
function mutation(pantary){
//Does pantary have listOfItems
for(let i = 0; i <= pantary[1].length-1;i++){
console.log(pantary[1][i])
}
}
mutation(['ab','ammar']);
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/143.0.0.0 Safari/537.36
Challenge Information:
Implement the Mutations Algorithm - Implement the Mutations Algorithm
When I have the first letter matching same letter in 1st string. I will want to move to the next word in second string.
My thought process was sorting words like 'Alien to check with ‘line’ If I do
It will easier to check, but now I think one outer loop is enough e.g. I will take the first letter of 2nd string and look for it in 1st string, if found, move onto next one and so forth but if I don’t find any or one of them, break the loop.
For my breaking down problem is a problem and how to solve is hard like not the programming or what to use in programming but in general solving a problem.
That’s really what programming is. Breaking a problem down so that you can solve it systematically / algorithmically. Then, you just implement that system in a language the computer understands.
don’t test it with hardcoded letters, it does not help to write the logic
try mutation(['localhost','c']);
try mutation(['localhost','v']);
and then mutation(['localhost','tc']);
and then mutation(['localhost','tcg']);
and then mutation(['localhost','tch']);
and then mutation(['localhost','tcih']);
the first should test true, the second should not, and so on
So I updated my code to take value from parameter, so right now it is like
function mutation(arr){
for(let i = 0; i <= arr[0].length - 1;i++){
if(arr[1] === arr[0][i]){
console.log(true)
}else{
console.log(false)
}
}
}
mutation(['localhost','c']);
I tried using arr[1][i] but it will compare each letter with another and move on like
e.g. ‘localhost’, ‘tsohlacol’ l will check if it is equal to h o will check if it is equal to s
but my thinking was that each word in the second array loop over each letter on first array to check, or am I thinking too much? and if so what can I do to help myself.